-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstring_test.go
47 lines (42 loc) · 1.45 KB
/
string_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package aoc
import "testing"
func TestReverseString(t *testing.T) {
name := "Krypton"
reversed := ReverseString(name)
expected := "notpyrK"
if reversed == expected {
t.Log("Successfully reversed the string")
return
}
t.Errorf("Failed reversing the string (got: %s, expected: %s)", reversed, expected)
}
func TestAtoi(t *testing.T) {
stringNumber := "1337"
converted := Atoi(stringNumber)
expected := 1337
if converted == expected {
t.Log("Successfully converted a string to an integer")
return
}
t.Errorf("Failed converting a string to an integer (got: %d, expected: %d)", converted, expected)
}
func TestContainsCharacters(t *testing.T) {
sentence := "the quick brown fox jumps over the lazy dog"
characters := "xyz"
contains := ContainsCharacters(sentence, characters)
if contains {
t.Log("Successfully checked if the characters of the substring is contained in the sentence")
return
}
t.Errorf("Failed checking if the characters of the substring is contained in the sentence (got: %t, expected: true)", contains)
}
func TestContainsExactly(t *testing.T) {
sentence := "thequickbrownfxjmpsvlazydg"
characters := "abcdefghijklmnopqrstuvwxyz"
contains := ContainsExactly(sentence, characters)
if contains {
t.Log("Successfully checked if the characters are in the sentence, and have the same length")
return
}
t.Errorf("Failed checking if the characters are in the sentence, and have the same length (got: %t, expected: true)", contains)
}