From 5eb16cccbc4aa98f8b3a1b698542a6522175582d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Coll?= Date: Thu, 4 Jul 2019 15:57:16 -0300 Subject: [PATCH] Add TrieTreeSizeTest --- .../java/co/rsk/trie/TrieTreeSizeTest.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 rskj-core/src/test/java/co/rsk/trie/TrieTreeSizeTest.java diff --git a/rskj-core/src/test/java/co/rsk/trie/TrieTreeSizeTest.java b/rskj-core/src/test/java/co/rsk/trie/TrieTreeSizeTest.java new file mode 100644 index 00000000000..7faf8900cd6 --- /dev/null +++ b/rskj-core/src/test/java/co/rsk/trie/TrieTreeSizeTest.java @@ -0,0 +1,49 @@ +/* + * This file is part of RskJ + * Copyright (C) 2019 RSK Labs Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package co.rsk.trie; + +import org.junit.Assert; +import org.junit.Test; + +import static org.hamcrest.Matchers.is; + +public class TrieTreeSizeTest { + @Test + public void emptyChildrenSize() { + Trie trie = new Trie(); + long emptyChildrenSize = trie.getChildrenSize().value; + Assert.assertThat(emptyChildrenSize, is(0L)); + } + + @Test + public void childrenSizeShortValue() { + Trie trie = new Trie() + .put(new byte[]{0x00}, new byte[]{0x01}) + .put(new byte[]{0x01}, new byte[32]); + Assert.assertThat(trie.getChildrenSize().value, is(37L)); + } + + @Test + public void childrenSizeLongValue() { + Trie trie = new Trie() + .put(new byte[]{0x00}, new byte[]{0x01}) + .put(new byte[]{0x01}, new byte[33]); + Assert.assertThat(trie.getChildrenSize().value, is(40L)); + } +} \ No newline at end of file