(t *testing.T)
| 96 | } |
| 97 | |
| 98 | func TestMatch_Getters(t *testing.T) { |
| 99 | matches := []string{"m0", "m1", "m2"} |
| 100 | names := []string{"", "n1", "n2"} |
| 101 | |
| 102 | t.Run("length", func(t *testing.T) { |
| 103 | reporter := newMockReporter(t) |
| 104 | |
| 105 | value := NewMatch(reporter, matches, names) |
| 106 | |
| 107 | innerValue := value.Length() |
| 108 | assert.Equal(t, 3.0, innerValue.Raw()) |
| 109 | |
| 110 | value.chain.assert(t, success) |
| 111 | innerValue.chain.assert(t, success) |
| 112 | }) |
| 113 | |
| 114 | t.Run("submatch", func(t *testing.T) { |
| 115 | reporter := newMockReporter(t) |
| 116 | |
| 117 | value := NewMatch(reporter, matches, names) |
| 118 | |
| 119 | for n := range matches { |
| 120 | innerValue := value.Submatch(n) |
| 121 | assert.Equal(t, matches[n], innerValue.Raw()) |
| 122 | |
| 123 | value.chain.assert(t, success) |
| 124 | innerValue.chain.assert(t, success) |
| 125 | } |
| 126 | }) |
| 127 | |
| 128 | t.Run("submatch out of range", func(t *testing.T) { |
| 129 | reporter := newMockReporter(t) |
| 130 | |
| 131 | value := NewMatch(reporter, matches, names) |
| 132 | |
| 133 | innerValue := value.Submatch(3) |
| 134 | assert.NotNil(t, innerValue) |
| 135 | |
| 136 | value.chain.assert(t, failure) |
| 137 | innerValue.chain.assert(t, failure) |
| 138 | }) |
| 139 | |
| 140 | t.Run("named submatch", func(t *testing.T) { |
| 141 | reporter := newMockReporter(t) |
| 142 | |
| 143 | value := NewMatch(reporter, matches, names) |
| 144 | |
| 145 | for n := range matches { |
| 146 | if names[n] == "" { |
| 147 | continue |
| 148 | } |
| 149 | innerValue := value.NamedSubmatch(names[n]) |
| 150 | assert.Equal(t, matches[n], innerValue.Raw()) |
| 151 | |
| 152 | value.chain.assert(t, success) |
| 153 | innerValue.chain.assert(t, success) |
| 154 | } |
| 155 | }) |
nothing calls this directly
no test coverage detected
searching dependent graphs…