From 70dbb5a599ec322551f00e0dbeac22ddb4942243 Mon Sep 17 00:00:00 2001 From: mjhalupka Date: Tue, 1 May 2018 15:01:07 -0700 Subject: Add a codec for LinkedHashSet. PiperOrigin-RevId: 195002908 --- .../serialization/LinkedHashSetCodecTest.java | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/test/java/com/google/devtools/build/lib/skyframe/serialization/LinkedHashSetCodecTest.java (limited to 'src/test/java/com/google/devtools/build') diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/serialization/LinkedHashSetCodecTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/serialization/LinkedHashSetCodecTest.java new file mode 100644 index 0000000000..2f0c095ec5 --- /dev/null +++ b/src/test/java/com/google/devtools/build/lib/skyframe/serialization/LinkedHashSetCodecTest.java @@ -0,0 +1,50 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.devtools.build.lib.skyframe.serialization; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.devtools.build.lib.skyframe.serialization.testutils.SerializationTester; +import com.google.devtools.build.lib.skyframe.serialization.testutils.SerializationTester.VerificationFunction; +import java.util.LinkedHashSet; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for {@link LinkedHashSetCodec}. */ +@RunWith(JUnit4.class) +public class LinkedHashSetCodecTest { + + @Test + public void smokeTest() throws Exception { + LinkedHashSet subjectTwo = new LinkedHashSet<>(); + subjectTwo.add("one"); + subjectTwo.add("two"); + subjectTwo.add("three"); + LinkedHashSet nullSet = new LinkedHashSet<>(); + nullSet.add(null); + LinkedHashSet mixedSet = new LinkedHashSet<>(); + mixedSet.add(null); + mixedSet.add("memberOne"); + new SerializationTester(new LinkedHashSet(), subjectTwo, nullSet, mixedSet) + .setVerificationFunction( + (VerificationFunction>) + (deserialized, subject) -> { + assertThat(deserialized).isEqualTo(subject); + assertThat(deserialized.size()).isEqualTo(subject.size()); + }) + .runTests(); + } +} -- cgit v1.2.3