-
Notifications
You must be signed in to change notification settings - Fork 8
/
config_test.go
41 lines (37 loc) · 1 KB
/
config_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
package csvutil
/*
* Filename: config_test.go
* Author: Bryan Matsuo <[email protected]>
* Created: Tue Jul 12 01:56:03 PDT 2011
* Description:
* Usage: gotest
*/
import (
"testing"
"unicode/utf8"
)
// Some rediculously dumb tests of Config methods, which are very simple.
func TestConfig(T *testing.T) {
var config = NewConfig()
// Test comment detection.
config.CommentPrefix = "//"
if !config.LooksLikeComment("// This should be a comment.\n") {
T.Error("Did not correctly identify a // comment")
}
if config.LooksLikeComment("/ This, is not, a comment\n") {
T.Error("Incorrectly labeled something a // comment")
}
// Test seperator detection.
config.Sep = '\t'
str := "\t"
c, n := utf8.DecodeRuneInString(str)
if c == utf8.RuneError && n == 1 {
T.Errorf("Could not decode rune in string %q", str)
}
if !config.IsSep(c) {
T.Error("Did not correctly identify a \\t separator")
}
if config.IsSep(52) {
T.Error("Incorrectly labelled 52 a \\t separator")
}
}