aboutsummaryrefslogtreecommitdiff
path: root/azalea-nbt/tests
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2023-03-11 16:38:13 -0600
committermat <github@matdoes.dev>2023-03-11 16:38:13 -0600
commit40a0c8acfbfb88be791c295a14014468e2fd4298 (patch)
tree54019c0f68d4bdfa944c4b2e80249dae858f302c /azalea-nbt/tests
parent81e7adb409199ac6594a18ca1bd88bfe89fbfc3e (diff)
downloadazalea-drasl-40a0c8acfbfb88be791c295a14014468e2fd4298.tar.xz
slightly optimize azalea_nbt::Tag::id
Diffstat (limited to 'azalea-nbt/tests')
-rwxr-xr-xazalea-nbt/tests/tests.rs29
1 files changed, 7 insertions, 22 deletions
diff --git a/azalea-nbt/tests/tests.rs b/azalea-nbt/tests/tests.rs
index 43c31590..c44eb818 100755
--- a/azalea-nbt/tests/tests.rs
+++ b/azalea-nbt/tests/tests.rs
@@ -1,16 +1,11 @@
use ahash::AHashMap;
use azalea_nbt::Tag;
-use std::{
- fs::File,
- io::{Cursor, Read},
-};
+use std::io::Cursor;
#[test]
fn test_decode_hello_world() {
// read hello_world.nbt
- let mut file = File::open("tests/hello_world.nbt").unwrap();
- let mut buf = vec![];
- file.read_to_end(&mut buf).unwrap();
+ let buf = include_bytes!("hello_world.nbt").to_vec();
let tag = Tag::read(&mut Cursor::new(&buf[..])).unwrap();
assert_eq!(
tag,
@@ -26,9 +21,7 @@ fn test_decode_hello_world() {
#[test]
fn test_roundtrip_hello_world() {
- let mut file = File::open("tests/hello_world.nbt").unwrap();
- let mut original = Vec::new();
- file.read_to_end(&mut original).unwrap();
+ let original = include_bytes!("hello_world.nbt").to_vec();
let mut original_stream = Cursor::new(&original[..]);
let tag = Tag::read(&mut original_stream).unwrap();
@@ -43,9 +36,7 @@ fn test_roundtrip_hello_world() {
#[test]
fn test_bigtest() {
// read bigtest.nbt
- let mut file = File::open("tests/bigtest.nbt").unwrap();
- let mut original = Vec::new();
- file.read_to_end(&mut original).unwrap();
+ let original = include_bytes!("bigtest.nbt").to_vec();
let mut original_stream = Cursor::new(original);
let original_tag = Tag::read_gzip(&mut original_stream).unwrap();
@@ -81,9 +72,7 @@ fn test_stringtest() {
Tag::String("😁".to_string()),
])
)]));
- let mut file = std::fs::File::open("tests/stringtest.nbt").unwrap();
- let mut original = Vec::new();
- file.read_to_end(&mut original).unwrap();
+ let original = include_bytes!("stringtest.nbt").to_vec();
let mut original_stream = Cursor::new(original);
let original_tag = Tag::read_gzip(&mut original_stream).unwrap();
@@ -93,9 +82,7 @@ fn test_stringtest() {
#[test]
fn test_complex_player() {
- let mut file = File::open("tests/complex_player.dat").unwrap();
- let mut original = Vec::new();
- file.read_to_end(&mut original).unwrap();
+ let original = include_bytes!("complex_player.dat").to_vec();
let mut original_stream = Cursor::new(original);
let original_tag = Tag::read_gzip(&mut original_stream).unwrap();
@@ -110,9 +97,7 @@ fn test_complex_player() {
#[test]
fn test_simple_player() {
- let mut file = File::open("tests/simple_player.dat").unwrap();
- let mut original = Vec::new();
- file.read_to_end(&mut original).unwrap();
+ let original = include_bytes!("simple_player.dat").to_vec();
let mut original_stream = Cursor::new(original);
let original_tag = Tag::read_gzip(&mut original_stream).unwrap();