Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

33
LINES

< > BotCompany Repo | #1027811 // test_TreeSetWithDuplicates

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2847L/18K).

1  
svoid test_TreeSetWithDuplicates() {
2  
  TreeSetWithDuplicates<S> set = new(comparatorFromCalculatedField l());
3  
  set.addAll(ll("hello", "world", "bla", "very long"));
4  
  assertEqualsOneOfVerbose(asList(set),
5  
    ll("bla", "hello", "world", "very long"),
6  
    ll("bla", "world", "hello", "very long"));
7  
  assertEqualsVerbose(4, set.size());
8  
  
9  
  // test all cases of size update
10  
  set.remove("x"); // remove element not in set
11  
  assertEqualsVerbose(4, set.size());
12  
  set.remove("bla"); // remove element without duplicates
13  
  assertEqualsVerbose(3, set.size());
14  
  set.remove("hello"); // remove element with a remaining duplicate
15  
  assertEqualsVerbose(2, set.size());
16  
  set.add("world"); // add existing element
17  
  assertEqualsVerbose(2, set.size());
18  
  set.add("old"); // add new element
19  
  assertEqualsVerbose(3, set.size());
20  
  set.add("new"); // add new element with existing duplicate
21  
  assertEqualsVerbose(4, set.size());
22  
  
23  
  test_TreeSetWithDuplicates_2();
24  
}
25  
26  
// test that elements with same probability are returned in
27  
// insertion order
28  
svoid test_TreeSetWithDuplicates_2() {
29  
  TreeSetWithDuplicates<S> set = new(comparatorFromCalculatedField l());
30  
  LS l = ll("abc", "xyz", "def", "ppp", "aaa");
31  
  set.addAll(l);
32  
  assertEqualsVerbose(l, asList(set));
33  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027811
Snippet name: test_TreeSetWithDuplicates
Eternal ID of this version: #1027811/8
Text MD5: 29817da96cb73c468c4ae2616d7e11ef
Transpilation MD5: 6f0e4fef5b3a3bf759820e131b0e001c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-04-23 11:48:27
Source code size: 1287 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 216 / 341
Version history: 7 change(s)
Referenced in: [show references]