Решение на FMI Buzz от Борис Петров
Обратно към всички решения
Към профила на Борис Петров
Резултати
- 12 точки от тестове
- 0 бонус точки
- 12 точки общо
- 8 успешни тест(а)
- 2 неуспешни тест(а)
Код
Лог от изпълнението
Compiling solution v0.1.0 (/tmp/d20201028-2816268-7bvofz/solution)
Finished test [unoptimized + debuginfo] target(s) in 2.08s
Running target/debug/deps/solution-ebb42508826ef2b4
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Running target/debug/deps/solution_test-9e954a53ed808c89
running 10 tests
test solution_test::test_change_label_basic ... ok
test solution_test::test_change_label_invalid ... ok
test solution_test::test_classic1 ... ok
test solution_test::test_classic2 ... ok
test solution_test::test_coefficients1 ... ok
test solution_test::test_coefficients2 ... ok
test solution_test::test_coefficients_invalid ... FAILED
test solution_test::test_struct_basic ... ok
test solution_test::test_struct_invalid ... FAILED
test solution_test::test_zeroes ... ok
failures:
---- solution_test::test_coefficients_invalid stdout ----
thread 'main' panicked at 'attempt to calculate the remainder with a divisor of zero', src/lib.rs:20:50
thread 'main' panicked at 'attempt to calculate the remainder with a divisor of zero', src/lib.rs:20:20
thread 'main' panicked at 'assertion failed: catch_unwind(|| { custom_buzz(10, 3, 1); }).is_err()', tests/solution_test.rs:66:5
---- solution_test::test_struct_invalid stdout ----
thread 'main' panicked at 'attempt to calculate the remainder with a divisor of zero', src/lib.rs:44:59
thread 'main' panicked at 'attempt to calculate the remainder with a divisor of zero', src/lib.rs:44:24
thread 'main' panicked at 'assertion failed: catch_unwind(|| { fizzbuzzer!(3, 1); }).is_err()', tests/solution_test.rs:102:5
failures:
solution_test::test_coefficients_invalid
solution_test::test_struct_invalid
test result: FAILED. 8 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out
error: test failed, to rerun pass '--test solution_test'
История (1 версия и 1 коментар)
Борис качи първо решение на 21.10.2020 22:35 (преди почти 5 години)
Вместо default-на стойност, по-скоро тук бих сложил
unreachable!()
, за да укажа, че това никога не би трябвало да се случи. Ако все пак се случи, значи горната логика някакси не е правилна и по-добре програмата да спре, вместо да генерира невалиден изход. Паниката лесно се вижда като бъг, невалидния изход по-трудно се забелязва и дебъгва.