Skip to content

Commit

Permalink
Add TrieTreeSizeTest
Browse files Browse the repository at this point in the history
  • Loading branch information
colltoaction authored and Diego López León committed Jul 4, 2019
1 parent 6df9109 commit 5eb16cc
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions rskj-core/src/test/java/co/rsk/trie/TrieTreeSizeTest.java
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

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));
}
}

0 comments on commit 5eb16cc

Please sign in to comment.