Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xzel23 committed Nov 27, 2023
1 parent e6b7c7e commit d1a6ad9
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,25 @@ void testOfWithMap() {
assertEquals("Value1", textAttributes.get("Key1"));
assertEquals("Value2", textAttributes.get("Key2"));
}
}

@Test
void none() {
TextAttributes ta = TextAttributes.none();
assertNotNull(ta);
assertTrue(ta.isEmpty());
}

@Test
void equalsAndHashCode() {
TextAttributes ta1 = TextAttributes.of(new Pair<>("key", "value"));
TextAttributes ta2 = TextAttributes.of(new Pair<>("key", "value"));
TextAttributes ta3 = TextAttributes.of(new Pair<>("key", "value2"));
TextAttributes ta4 = TextAttributes.of(new Pair<>("key1", "value"));
assertEquals(ta1.hashCode(), ta2.hashCode());
assertEquals(ta1.hashCode(), ta1.hashCode());
assertNotEquals(ta1.hashCode(), ta3.hashCode());
assertNotEquals(ta1.hashCode(), ta4.hashCode());
assertNotEquals(ta3.hashCode(), ta4.hashCode());
assertTrue(ta1.equals(ta2));
}
}

0 comments on commit d1a6ad9

Please sign in to comment.