Решение на Network Packets от Иван Велков
Обратно към всички решения
Към профила на Иван Велков
Резултати
- 1 точка от тестове
- 0 бонус точки
- 1 точка общо
- 1 успешни тест(а)
- 14 неуспешни тест(а)
Код
Лог от изпълнението
Compiling solution v0.1.0 (/tmp/d20200111-2173579-1j04a2u/solution)
warning: unnecessary parentheses around `if` condition
--> src/lib.rs:61:12
|
61 | if (size as usize > source.len()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these parentheses
|
= note: `#[warn(unused_parens)]` on by default
warning: unnecessary parentheses around `if` condition
--> src/lib.rs:135:11
|
135 | if(self.packets.len() > 0) {
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these parentheses
warning: unused variable: `packet_size`
--> src/lib.rs:162:26
|
162 | fn to_packets(&self, packet_size: u8) -> PacketSerializer {
| ^^^^^^^^^^^ help: consider prefixing with an underscore: `_packet_size`
|
= note: `#[warn(unused_variables)]` on by default
warning: unused variable: `packet_size`
--> src/lib.rs:172:30
|
172 | fn to_packet_data(&self, packet_size: u8) -> Vec<u8> {
| ^^^^^^^^^^^ help: consider prefixing with an underscore: `_packet_size`
warning: unused variable: `packet_data`
--> src/lib.rs:186:25
|
186 | fn from_packet_data(packet_data: &[u8]) -> Result<Self, PacketError> {
| ^^^^^^^^^^^ help: consider prefixing with an underscore: `_packet_data`
warning: unnecessary parentheses around `if` condition
--> src/lib.rs:61:12
|
61 | if (size as usize > source.len()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these parentheses
|
= note: `#[warn(unused_parens)]` on by default
warning: unnecessary parentheses around `if` condition
--> src/lib.rs:135:11
|
135 | if(self.packets.len() > 0) {
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these parentheses
warning: unused variable: `packet_size`
--> src/lib.rs:162:26
|
162 | fn to_packets(&self, packet_size: u8) -> PacketSerializer {
| ^^^^^^^^^^^ help: consider prefixing with an underscore: `_packet_size`
|
= note: `#[warn(unused_variables)]` on by default
warning: unused variable: `packet_size`
--> src/lib.rs:172:30
|
172 | fn to_packet_data(&self, packet_size: u8) -> Vec<u8> {
| ^^^^^^^^^^^ help: consider prefixing with an underscore: `_packet_size`
warning: unused variable: `packet_data`
--> src/lib.rs:186:25
|
186 | fn from_packet_data(packet_data: &[u8]) -> Result<Self, PacketError> {
| ^^^^^^^^^^^ help: consider prefixing with an underscore: `_packet_data`
Finished test [unoptimized + debuginfo] target(s) in 3.54s
Running target/debug/deps/solution-a73e64ec87929bd0
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Running target/debug/deps/solution_test-38971695424b36d5
running 15 tests
test solution_test::test_construct_packet_from_unicode ... FAILED
test solution_test::test_construct_packet_no_remainder ... FAILED
test solution_test::test_construct_packet_with_remainder ... FAILED
test solution_test::test_construct_packet_with_remainder_cyrillic ... FAILED
test solution_test::test_consuming_packets ... thread '<unnamed>' panicked at 'not yet implemented', src/lib.rs:163:9
FAILED
test solution_test::test_deserialize_invalid_packet ... FAILED
test solution_test::test_deserialize_packet ... FAILED
test solution_test::test_deserialize_unicode_packet ... FAILED
test solution_test::test_full_roundtrip ... thread '<unnamed>' panicked at 'not yet implemented', src/lib.rs:173:9
FAILED
test solution_test::test_full_roundtrip_for_zero_size_string ... thread '<unnamed>' panicked at 'not yet implemented', src/lib.rs:173:9
FAILED
test solution_test::test_invalid_packet_combination ... thread '<unnamed>' panicked at 'not yet implemented', src/lib.rs:163:9
FAILED
test solution_test::test_iterating_packets ... thread '<unnamed>' panicked at 'not yet implemented', src/lib.rs:163:9
FAILED
test solution_test::test_iterating_packets_for_zero_size_string ... thread '<unnamed>' panicked at 'not yet implemented', src/lib.rs:163:9
FAILED
test solution_test::test_serialize_packet ... FAILED
test solution_test::test_zero_size ... ok
failures:
---- solution_test::test_construct_packet_from_unicode stdout ----
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `[209, 128, 208, 176, 208]`,
right: `[209, 128, 208, 176, 208, 183]`', tests/solution_test.rs:83:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
---- solution_test::test_construct_packet_no_remainder stdout ----
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `[208, 177, 208, 176, 208, 177, 208]`,
right: `[208, 177, 208, 176, 208, 177, 208, 176]`', tests/solution_test.rs:47:5
---- solution_test::test_construct_packet_with_remainder stdout ----
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `[116, 101, 115, 116]`,
right: `[116, 101, 115, 116, 32]`', tests/solution_test.rs:54:5
---- solution_test::test_construct_packet_with_remainder_cyrillic stdout ----
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `[208, 180, 209]`,
right: `[208, 180, 209, 143]`', tests/solution_test.rs:65:5
---- solution_test::test_consuming_packets stdout ----
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21
---- solution_test::test_deserialize_invalid_packet stdout ----
thread 'main' panicked at 'Expression Ok((Packet { version: 2, size: 2, payload: [2] }, [107])) does not match the pattern "Err(PacketError::UnknownProtocolVersion)"', tests/solution_test.rs:147:5
---- solution_test::test_deserialize_packet stdout ----
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `(Packet { version: 1, size: 1, payload: [] }, [1, 107])`,
right: `(Packet { version: 1, size: 3, payload: [120, 121, 122] }, [])`', tests/solution_test.rs:114:5
---- solution_test::test_deserialize_unicode_packet stdout ----
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `(Packet { version: 1, size: 1, payload: [] }, [130, 209, 128, 208, 190, 0, 0, 7, 16])`,
right: `(Packet { version: 1, size: 10, payload: [209, 133, 208, 184, 209, 130, 209, 128, 208, 190] }, [])`', tests/solution_test.rs:131:5
---- solution_test::test_full_roundtrip stdout ----
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21
---- solution_test::test_full_roundtrip_for_zero_size_string stdout ----
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21
---- solution_test::test_invalid_packet_combination stdout ----
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21
---- solution_test::test_iterating_packets stdout ----
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21
---- solution_test::test_iterating_packets_for_zero_size_string stdout ----
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21
---- solution_test::test_serialize_packet stdout ----
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `[0, 0, 0, 5]`,
right: `[0, 0, 1, 107]`', tests/solution_test.rs:103:5
failures:
solution_test::test_construct_packet_from_unicode
solution_test::test_construct_packet_no_remainder
solution_test::test_construct_packet_with_remainder
solution_test::test_construct_packet_with_remainder_cyrillic
solution_test::test_consuming_packets
solution_test::test_deserialize_invalid_packet
solution_test::test_deserialize_packet
solution_test::test_deserialize_unicode_packet
solution_test::test_full_roundtrip
solution_test::test_full_roundtrip_for_zero_size_string
solution_test::test_invalid_packet_combination
solution_test::test_iterating_packets
solution_test::test_iterating_packets_for_zero_size_string
solution_test::test_serialize_packet
test result: FAILED. 1 passed; 14 failed; 0 ignored; 0 measured; 0 filtered out
error: test failed, to rerun pass '--test solution_test'
История (1 версия и 3 коментара)
Иван качи първо решение на 03.12.2019 16:42 (преди почти 6 години)
Технически погледнато, това е работещо решение, I guess.
Evil, evil, ама поне да работеше.
lol