From 69f3b57d36f2b93ba0c487294ffd704774710433 Mon Sep 17 00:00:00 2001 From: surajdm123 Date: Wed, 2 Jul 2025 17:56:54 -0700 Subject: [PATCH] Added test for Pair.java --- src/test/groovy/graphql/util/PairTest.groovy | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/test/groovy/graphql/util/PairTest.groovy diff --git a/src/test/groovy/graphql/util/PairTest.groovy b/src/test/groovy/graphql/util/PairTest.groovy new file mode 100644 index 000000000..f64f9127a --- /dev/null +++ b/src/test/groovy/graphql/util/PairTest.groovy @@ -0,0 +1,31 @@ +package graphql.util + +import spock.lang.Specification + +class PairTest extends Specification { + def "constructor initializes fields correctly"() { + when: + def pair = new Pair<>("hello", 123) + + then: + pair.first == "hello" + pair.second == 123 + } + + def "static pair method creates Pair instance"() { + when: + def pair = Pair.pair("foo", "bar") + + then: + pair instanceof Pair + pair.first == "foo" + pair.second == "bar" + } + + def "toString returns formatted string"() { + expect: + new Pair<>(1, 2).toString() == "(1, 2)" + Pair.pair("a", "b").toString() == "(a, b)" + new Pair<>(null, null).toString() == "(null, null)" + } +}