static void tree_add_basic_test();
static void tree_add_extended_test();
static void tree_bencode_basic_test();
+static void tree_bencode_length_basic_test();
static void tree_init_basic_test();
int main() {
tree_add_basic_test();
tree_bencode_basic_test();
tree_add_extended_test();
+ tree_bencode_length_basic_test();
clean_env();
tree_free(root);
}
+static void tree_bencode_length_basic_test() {
+ struct tree *root;
+ struct file *file;
+ char fileA_path[] = "dir1/dir2/fileA.txt";
+ char fileB_path[] = "test/hello/notadirectory.nope";
+
+ assert(1==tree_init(&root));
+
+ assert(1==file_init(&file,fileA_path));
+ memset(file->root,48,crypto_hash_sha256_BYTES);
+ file->size = 1024;
+
+ assert(1==tree_add(root,file->path,file));
+
+ assert(98==tree_bencode_length(root));
+
+ assert(1==file_init(&file,fileB_path));
+ memset(file->root,48,crypto_hash_sha256_BYTES);
+ file->size = 512;
+
+ assert(1==tree_add(root,file->path,file));
+
+ assert(204==tree_bencode_length(root));
+
+ tree_free(root);
+}
+
static void tree_init_basic_test() {
struct tree *p;