1 package minify 2 3 import "testing" 4 5 func TestIsIdentifier(t *testing.T) { 6 for n, test := range [...]struct { 7 Input string 8 IsIdentifier bool 9 }{ 10 { 11 "a", 12 true, 13 }, 14 { 15 "aa", 16 true, 17 }, 18 { 19 "_", 20 true, 21 }, 22 { 23 "__", 24 true, 25 }, 26 { 27 "0", 28 false, 29 }, 30 { 31 "true", 32 true, 33 }, 34 { 35 "a a", 36 false, 37 }, 38 } { 39 if ii := isIdentifier(test.Input); ii != test.IsIdentifier { 40 t.Errorf("test %d: for input %q, expecting IsIdentifier to return %v, got %v", n+1, test.Input, test.IsIdentifier, ii) 41 } 42 } 43 } 44 45 func TestIsSimpleNumber(t *testing.T) { 46 for n, test := range [...]struct { 47 Input string 48 IsSimpleNumber bool 49 }{ 50 { 51 "", 52 false, 53 }, 54 { 55 "a", 56 false, 57 }, 58 { 59 "0", 60 true, 61 }, 62 { 63 "01", 64 false, 65 }, 66 { 67 "1", 68 true, 69 }, 70 { 71 "1234567890", 72 true, 73 }, 74 { 75 "1234567890a", 76 false, 77 }, 78 { 79 "9007199254740990", 80 true, 81 }, 82 { 83 "9007199254740991", 84 true, 85 }, 86 { 87 "9007199254740992", 88 false, 89 }, 90 { 91 "19007199254740992", 92 false, 93 }, 94 } { 95 if isn := isSimpleNumber(test.Input); isn != test.IsSimpleNumber { 96 t.Errorf("test %d: for input %s, got %v, when expecting %v", n+1, test.Input, test.IsSimpleNumber, isn) 97 } 98 } 99 } 100