Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3cf5a4
commit fcdf295
Showing
11 changed files
with
92 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package code | ||
|
||
import ( | ||
"github.com/Mobilpadde/moths/v4/token/emojies" | ||
) | ||
|
||
type Code struct { | ||
token string | ||
emojies emojies.Emojies | ||
} | ||
|
||
func (code Code) Token() string { | ||
return code.token | ||
} | ||
|
||
func (code Code) String() string { | ||
return code.emojies.String() | ||
} | ||
|
||
func (code Code) SpacedString() string { | ||
return code.emojies.SpacedString() | ||
} | ||
|
||
func (code Code) Slice() []string { | ||
return code.emojies.Slice() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package code | ||
|
||
func (code Code) Validate(emojies string) bool { | ||
return code.String() == emojies | ||
} | ||
|
||
func (code Code) ValidateToken(token string) bool { | ||
return code.Token() == token | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package code | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/Mobilpadde/moths/v4/token/emojies" | ||
) | ||
|
||
func TestValidate(t *testing.T) { | ||
amount := 6 | ||
token := "000000" | ||
correct := "😸😼😹😺😸😻" | ||
|
||
code, err := NewCode(token, amount, emojies.CATS) | ||
if err != nil { | ||
t.Error("Expected to not return an error when creating new code:", err) | ||
} | ||
|
||
if !code.Validate(correct) { | ||
t.Error("Expected code to be", correct, "not", code.emojies) | ||
} | ||
} | ||
|
||
func TestValidateToken(t *testing.T) { | ||
amount := 6 | ||
token := "000000" | ||
|
||
code, err := NewCode(token, amount, emojies.CATS) | ||
if err != nil { | ||
t.Error("Expected to not return an error when creating new code:", err) | ||
} | ||
|
||
if !code.ValidateToken(token) { | ||
t.Error("Expected code to be", token, "not", code.token) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters