| 123456789101112131415161718192021222324252627282930313233 |
- package solver
- import (
- "testing"
- )
- // Test the calcAVG function.
- func TestCalcAVG(t *testing.T) {
- // Create a new Solver struct.
- solver := Solver{}
- // Populate the solver.rates[] slice with some values and check if the average is calculated correctly.
- solver.rates = []uint64{1, 2, 3, 4, 5}
- if solver.calcAVG() != 3 {
- t.Error("Expected 3, got", solver.calcAVG())
- }
- // Populate the solver.Rate[] slice with some values and check if the average is calculated correctly.
- solver.rates = []uint64{1, 2, 3, 4, 5, 6}
- if solver.calcAVG() != 3 {
- t.Error("Expected 3, got", solver.calcAVG())
- }
- // Populate the solver.Rate[] slice with some values and check if the average is calculated correctly.
- solver.rates = []uint64{1, 2, 3, 4, 5, 6, 7}
- if solver.calcAVG() != 4 {
- t.Error("Expected 4, got", solver.calcAVG())
- }
- // Populate the solver.Rate[] slice with some values and check if the average is calculated correctly.
- solver.rates = []uint64{1, 2, 3, 4, 5, 6, 7, 8}
- if solver.calcAVG() != 4 {
- t.Error("Expected 4, got", solver.calcAVG())
- }
- }
|