ValueTest.java
/***************************************************************************
Copyright 2015 Emily Estes
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 net.metanotion.sqltest;
import java.util.ArrayList;
import java.util.HashMap;
public final class ValueTest {
private static void assertTrue(final boolean result) {
if(!result) { throw new AssertionError("Expected true"); }
}
public static void main(final String[] args) throws Exception {
final HashMap<String,Value> env = new HashMap<>();
final HashMap<String,Object> expected = new HashMap<>();
final HashMap<String,Object> actual = new HashMap<>();
assertTrue(RowValue.compareMap(expected, expected, env));
assertTrue(RowValue.compareMap(expected, actual, env));
expected.put("test", 1);
assertTrue(RowValue.compareMap(expected, expected, env));
assertTrue(!RowValue.compareMap(expected, actual, env));
actual.put(new String("test"), new Integer(1));
assertTrue(RowValue.compareMap(expected, actual, env));
actual.put("test", 2);
assertTrue(!RowValue.compareMap(expected, actual, env));
final ArrayList<Object> eList = new ArrayList<>();
final ArrayList<Object> aList = new ArrayList<>();
assertTrue(ListValue.compareIterator(eList, aList.iterator(), env));
eList.add(1);
aList.add(1);
assertTrue(ListValue.compareIterator(eList, aList.iterator(), env));
eList.clear();
aList.clear();
eList.add(expected);
assertTrue(ListValue.compareIterator(eList, eList.iterator(), env));
actual.put("test", 1);
aList.add(actual);
assertTrue(ListValue.compareIterator(eList, aList.iterator(), env));
}
}