(t *testing.T)
| 122 | } |
| 123 | |
| 124 | func TestGFPolyRemainder(t *testing.T) { |
| 125 | // numerator / denominator == quotient + remainder. |
| 126 | var tests = []struct { |
| 127 | numerator gfPoly |
| 128 | denominator gfPoly |
| 129 | remainder gfPoly |
| 130 | }{ |
| 131 | { |
| 132 | gfPoly{[]gfElement{1}}, |
| 133 | gfPoly{[]gfElement{1}}, |
| 134 | gfPoly{[]gfElement{0}}, |
| 135 | }, |
| 136 | { |
| 137 | gfPoly{[]gfElement{1, 0}}, |
| 138 | gfPoly{[]gfElement{1}}, |
| 139 | gfPoly{[]gfElement{0}}, |
| 140 | }, |
| 141 | { |
| 142 | gfPoly{[]gfElement{1}}, |
| 143 | gfPoly{[]gfElement{1, 0}}, |
| 144 | gfPoly{[]gfElement{1}}, |
| 145 | }, |
| 146 | { |
| 147 | gfPoly{[]gfElement{1, 0, 1}}, |
| 148 | gfPoly{[]gfElement{0, 1}}, |
| 149 | gfPoly{[]gfElement{1}}, |
| 150 | }, |
| 151 | // (x^12 + x^10) / (x^10 + x^8 + x^5 + x^4 + x^2 + x^1 + x^0) = |
| 152 | // (x^10 + x^8 + x^5 + x^4 + x^2 + x^1 + x^0) * x^2 + |
| 153 | // (x^7 + x^6 + x^4 + x^3 + x^2) (the remainder) |
| 154 | { |
| 155 | gfPoly{[]gfElement{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1}}, |
| 156 | gfPoly{[]gfElement{1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1}}, |
| 157 | gfPoly{[]gfElement{0, 0, 1, 1, 1, 0, 1, 1}}, |
| 158 | }, |
| 159 | { |
| 160 | gfPoly{[]gfElement{91, 50, 25, 184, 194, 105, 45, 244, 58, 44}}, |
| 161 | gfPoly{[]gfElement{254, 120, 88, 44, 11, 1}}, |
| 162 | gfPoly{[]gfElement{}}, |
| 163 | }, |
| 164 | { |
| 165 | gfPoly{[]gfElement{0, 0, 0, 0, 0, 0, 195, 172, 24, 64}}, |
| 166 | gfPoly{[]gfElement{116, 147, 63, 198, 31, 1}}, |
| 167 | gfPoly{[]gfElement{48, 174, 34, 13, 134}}, |
| 168 | }, |
| 169 | } |
| 170 | |
| 171 | for _, test := range tests { |
| 172 | remainder := gfPolyRemainder(test.numerator, test.denominator) |
| 173 | |
| 174 | if !test.remainder.equals(remainder) { |
| 175 | t.Errorf("%s / %s, remainder = %s (got %s)\n", |
| 176 | test.numerator.string(false), |
| 177 | test.denominator.string(false), |
| 178 | test.remainder.string(false), |
| 179 | remainder.string(false)) |
| 180 | } |
| 181 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…