-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a42f14b
commit 8ff0fdc
Showing
2 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { describe, test, expect, beforeEach, afterEach } from "vitest"; | ||
import { GSet } from "../src/builtins/GSet"; | ||
|
||
describe("G-Set Tests", () => { | ||
|
||
let set1: GSet<string>; | ||
let set2: GSet<string>; | ||
|
||
beforeEach(() => { | ||
set1 = new GSet<string>(new Set<string>(["walter", "jesse", "mike"])); | ||
set2 = new GSet<string>(new Set<string>(["walter", "jesse", "mike"])); | ||
}); | ||
|
||
test("Test Add", () => { | ||
set1.add("gustavo"); | ||
set2.add("gustavo"); | ||
|
||
expect(set1.lookup("gustavo")).toBe(true); | ||
expect(set2.lookup("gustavo")).toBe(true); | ||
}); | ||
|
||
test("Test Compare", () => { | ||
expect(set1.compare(set2)).toBe(true); | ||
|
||
set1.add("gustavo"); | ||
|
||
expect(set1.compare(set2)).toBe(false); | ||
|
||
set2.add("gustavo"); | ||
|
||
expect(set1.compare(set2)).toBe(true); | ||
}); | ||
|
||
test("Test Merge", () => { | ||
set1.add("gustavo"); | ||
set2.add("lalo"); | ||
|
||
expect(set1.compare(set2)).toBe(false); | ||
|
||
set1.merge(set2); | ||
set2.merge(set1); | ||
|
||
expect(set1.compare(set2)).toBe(true); | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { describe, test, expect, beforeEach } from "vitest"; | ||
import { TwoPSet } from "../src/builtins/2PSet"; | ||
import { GSet } from "../src/builtins/GSet"; | ||
|
||
describe("2P-Set Tests", () => { | ||
|
||
let set1: TwoPSet<string>; | ||
let set2: TwoPSet<string>; | ||
|
||
beforeEach(() => { | ||
set1 = new TwoPSet<string>(new GSet<string>(new Set<string>(["walter", "jesse", "mike"])), new GSet<string>(new Set<string>())); | ||
set2 = new TwoPSet<string>(new GSet<string>(new Set<string>(["walter", "jesse", "mike"])), new GSet<string>(new Set<string>())); | ||
}); | ||
|
||
test("Test Add Element", () => { | ||
expect(set1.lookup("gustavo")).toBe(false); | ||
|
||
set1.add("gustavo"); | ||
|
||
expect(set1.lookup("gustavo")).toBe(true); | ||
}); | ||
|
||
test("Test Remove Element", () => { | ||
expect(set1.lookup("mike")).toBe(true); | ||
|
||
set1.remove("mike"); | ||
|
||
expect(set1.lookup("mike")).toBe(false); | ||
}); | ||
|
||
test("Test Compare Elements", () => { | ||
expect(set1.compare(set2)).toBe(true); | ||
|
||
set1.remove("mike"); | ||
|
||
expect(set1.compare(set2)).toBe(false); | ||
|
||
set2.remove("mike"); | ||
|
||
expect(set1.compare(set2)).toBe(true); | ||
}); | ||
|
||
test("Test Merge Elements", () => { | ||
set1.remove("mike"); | ||
set2.add("gustavo"); | ||
|
||
expect(set1.compare(set2)).toBe(false); | ||
|
||
set1.merge(set2); | ||
set2.merge(set1); | ||
|
||
expect(set1.compare(set2)).toBe(true); | ||
}); | ||
|
||
}); |