43 lines
922 B
Odin
43 lines
922 B
Odin
package assets
|
|
|
|
import "core:testing"
|
|
|
|
@(private = "file")
|
|
test_csv := `
|
|
rpm,torque
|
|
1000,100
|
|
2000,110.5
|
|
5000,354.123
|
|
`
|
|
|
|
|
|
@(private = "file")
|
|
test_invalid_csv := `
|
|
rpm,torque
|
|
rpm,torque
|
|
1000,100
|
|
2000,110.5
|
|
5000,354.123
|
|
`
|
|
|
|
|
|
@(test)
|
|
test_curve_parsing :: proc(t: ^testing.T) {
|
|
curve, err := parse_csv_2d(transmute([]u8)test_csv, context.temp_allocator)
|
|
|
|
testing.expect_value(t, err, nil)
|
|
testing.expect_value(t, len(curve.points), 3)
|
|
testing.expect_value(t, curve.points[0], [2]f32{1000, 100})
|
|
testing.expect_value(t, curve.points[1], [2]f32{2000, 110.5})
|
|
testing.expect_value(t, curve.points[2], [2]f32{5000, 354.123})
|
|
}
|
|
|
|
@(test)
|
|
test_curve_parsing_error :: proc(t: ^testing.T) {
|
|
curve, err := parse_csv_2d(transmute([]u8)test_invalid_csv, context.temp_allocator)
|
|
defer free_all(context.temp_allocator)
|
|
|
|
testing.expect_value(t, err, CSV_Parse_Error.CSV_Parse_Error)
|
|
testing.expect_value(t, len(curve.points), 0)
|
|
}
|