Skip to content

Commit

Permalink
58: records test
Browse files Browse the repository at this point in the history
  • Loading branch information
skapral committed Sep 24, 2023
1 parent d0a3474 commit 6aecfa0
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*-
* ===========================================================================
* equivalence-itests.test-cases
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Copyright (C) 2019 - 2023 Kapralov Sergey
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* ============================================================================
*/
package com.pragmaticobjects.oo.equivalence.itests.records;

import com.pragmaticobjects.oo.equivalence.assertions.AssertCombined;
import com.pragmaticobjects.oo.equivalence.assertions.AssertEqualsResult;
import com.pragmaticobjects.oo.equivalence.assertions.TestCase;
import com.pragmaticobjects.oo.equivalence.assertions.TestsSuite;
import com.pragmaticobjects.oo.equivalence.itests.classes.Counter;

import java.util.HashMap;
import java.util.Map;

public class TestRecords extends TestsSuite {
private static final Map<String, Object> CONSTANT = new HashMap<>();

public TestRecords() {
super(
new TestCase(
"Test record with non-equivalent fields",
new AssertCombined(
new AssertEqualsResult(
new TRecord<>(CONSTANT),
new TRecord<>(CONSTANT),
true
),
new AssertEqualsResult(
new TRecord<>(new HashMap<>()),
new TRecord<>(new HashMap<>()),
false
)
)
),
new TestCase(
"Test record with equivalent fields",
new AssertCombined(
new AssertEqualsResult(
new TRecord<>(new Counter("A")),
new TRecord<>(new Counter("A")),
true
),
new AssertEqualsResult(
new TRecord<>(new Counter("A")),
new TRecord<>(new Counter("B")),
false
)
)
)
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*-
* ===========================================================================
* equivalence-itests.test-cases
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Copyright (C) 2019 - 2023 Kapralov Sergey
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* ============================================================================
*/
package com.pragmaticobjects.oo.equivalence.itests.records;
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
*/
package com.pragmaticobjects.oo.equivalence.itests.records;

public record PointRecord(int x, int y) {
public record TRecord<T>(T value) {
}

0 comments on commit 6aecfa0

Please sign in to comment.