Path: blob/master/test/langtools/tools/sjavac/util/OptionTestUtil.java
41149 views
/*1* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package util;2425import java.nio.file.Path;26import java.util.Collection;27import java.util.HashSet;28import java.util.Iterator;29import java.util.List;3031import com.sun.tools.sjavac.options.SourceLocation;323334public class OptionTestUtil {3536public static void checkFilesFound(Collection<String> found, Path... expected) {3738Collection<String> expectedStrs = new HashSet<String>();39for (Path p : expected)40expectedStrs.add(p.toString());4142if (!expectedStrs.containsAll(found))43throw new AssertionError("Expected (" + expectedStrs + ") does not " +44"contain all actual (" + found + ")");4546if (!found.containsAll(expectedStrs))47throw new AssertionError("Actual (" + found + ") does not " +48"contain all expected (" + expectedStrs + ")");49}5051public static void assertEquals(List<SourceLocation> expected, List<SourceLocation> actual) {52if (expected.size() != actual.size())53throw new AssertionError("Expected locs of length " + expected.size() + " but got something of size " + actual.size());5455Iterator<SourceLocation> iter1 = expected.iterator();56Iterator<SourceLocation> iter2 = actual.iterator();5758while (iter1.hasNext()) {59SourceLocation sl1 = iter1.next();60SourceLocation sl2 = iter2.next();6162if (!sl1.getPath().equals(sl2.getPath()) ||63!sl1.getIncludes().equals(sl2.getIncludes()) ||64!sl1.getExcludes().equals(sl2.getExcludes()))65throw new AssertionError("Expected " + sl1 + " but got " + sl2);66}67}6869public static void assertEquals(Object expected, Object actual) {70if (!expected.equals(actual))71throw new AssertionError("Expected " + expected + " but got " + actual);72}7374}757677