Merge branch 'master' into cpp17-hexadecimal-floating-literals
This commit is contained in:
commit
b0f105fa9f
113 changed files with 1848 additions and 295 deletions
|
|
@ -576,7 +576,7 @@ CPP11_TEST_CASES += \
|
|||
cpp11_initializer_list \
|
||||
cpp11_initializer_list_extend \
|
||||
cpp11_lambda_functions \
|
||||
cpp11_li_std_array \
|
||||
cpp11_std_array \
|
||||
cpp11_noexcept \
|
||||
cpp11_null_pointer_constant \
|
||||
cpp11_raw_string_literals \
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%module cpp11_li_std_array
|
||||
%module cpp11_std_array
|
||||
|
||||
#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGJAVA) || defined(SWIGCSHARP)
|
||||
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
%module cpp11_std_unordered_map
|
||||
|
||||
%include <std_string.i>
|
||||
%include <std_unordered_map.i>
|
||||
|
||||
%template(UnorderedMapIntInt) std::unordered_map<int, int>;
|
||||
%template(UnorderedMapStringInt) std::unordered_map<std::string, int>;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
%module cpp11_std_unordered_set
|
||||
|
||||
%include <std_string.i>
|
||||
%include <std_unordered_set.i>
|
||||
|
||||
%template(UnorderedSetInt) std::unordered_set<int>;
|
||||
%template(UnorderedSetString) std::unordered_set<std::string>;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
// This test tests all the methods in the C# collection wrapper
|
||||
using System;
|
||||
using cpp11_li_std_arrayNamespace;
|
||||
using cpp11_std_arrayNamespace;
|
||||
|
||||
public class cpp11_li_std_array_runme
|
||||
public class cpp11_std_array_runme
|
||||
{
|
||||
private static ArrayInt6 ToArray6(int[] a)
|
||||
{
|
||||
|
|
@ -37,24 +37,24 @@ public class cpp11_li_std_array_runme
|
|||
compareContainers(ai, vals);
|
||||
|
||||
// Check return
|
||||
compareContainers(cpp11_li_std_array.arrayOutVal(), new int[] { -2, -1, 0, 0, 1, 2 });
|
||||
compareContainers(cpp11_li_std_array.arrayOutConstRef(), new int[] { -2, -1, 0, 0, 1, 2 });
|
||||
compareContainers(cpp11_li_std_array.arrayOutRef(), new int[] { -2, -1, 0, 0, 1, 2 });
|
||||
compareContainers(cpp11_li_std_array.arrayOutPtr(), new int[] { -2, -1, 0, 0, 1, 2 });
|
||||
compareContainers(cpp11_std_array.arrayOutVal(), new int[] { -2, -1, 0, 0, 1, 2 });
|
||||
compareContainers(cpp11_std_array.arrayOutConstRef(), new int[] { -2, -1, 0, 0, 1, 2 });
|
||||
compareContainers(cpp11_std_array.arrayOutRef(), new int[] { -2, -1, 0, 0, 1, 2 });
|
||||
compareContainers(cpp11_std_array.arrayOutPtr(), new int[] { -2, -1, 0, 0, 1, 2 });
|
||||
|
||||
// Check passing arguments
|
||||
ai = cpp11_li_std_array.arrayInVal(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
|
||||
ai = cpp11_std_array.arrayInVal(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
|
||||
compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 });
|
||||
|
||||
ai = cpp11_li_std_array.arrayInConstRef(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
|
||||
ai = cpp11_std_array.arrayInConstRef(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
|
||||
compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 });
|
||||
|
||||
ai = new ArrayInt6(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
|
||||
cpp11_li_std_array.arrayInRef(ai);
|
||||
cpp11_std_array.arrayInRef(ai);
|
||||
compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 });
|
||||
|
||||
ai = new ArrayInt6(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
|
||||
cpp11_li_std_array.arrayInPtr(ai);
|
||||
cpp11_std_array.arrayInPtr(ai);
|
||||
compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 });
|
||||
|
||||
// fill
|
||||
|
|
@ -44,6 +44,8 @@ CPP_TEST_CASES = \
|
|||
java_typemaps_proxy \
|
||||
java_typemaps_typewrapper \
|
||||
li_std_list \
|
||||
li_std_map \
|
||||
li_std_set \
|
||||
# li_boost_intrusive_ptr
|
||||
|
||||
CPP11_TEST_CASES = \
|
||||
|
|
@ -51,6 +53,8 @@ CPP11_TEST_CASES = \
|
|||
cpp11_shared_ptr_nullptr_in_containers \
|
||||
cpp11_shared_ptr_overload \
|
||||
cpp11_shared_ptr_upcast \
|
||||
cpp11_std_unordered_map \
|
||||
cpp11_std_unordered_set \
|
||||
cpp11_strongly_typed_enumerations_simple \
|
||||
|
||||
DOXYGEN_TEST_CASES := \
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import cpp11_li_std_array.*;
|
||||
import cpp11_std_array.*;
|
||||
|
||||
public class cpp11_li_std_array_runme {
|
||||
public class cpp11_std_array_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp11_li_std_array");
|
||||
System.loadLibrary("cpp11_std_array");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
|
|
@ -43,24 +43,24 @@ public class cpp11_li_std_array_runme {
|
|||
compareContainers(ai, vals);
|
||||
|
||||
// Check return
|
||||
compareContainers(cpp11_li_std_array.arrayOutVal(), new int[] {-2, -1, 0, 0, 1, 2});
|
||||
compareContainers(cpp11_li_std_array.arrayOutConstRef(), new int[] {-2, -1, 0, 0, 1, 2});
|
||||
compareContainers(cpp11_li_std_array.arrayOutRef(), new int[] {-2, -1, 0, 0, 1, 2});
|
||||
compareContainers(cpp11_li_std_array.arrayOutPtr(), new int[] {-2, -1, 0, 0, 1, 2});
|
||||
compareContainers(cpp11_std_array.arrayOutVal(), new int[] {-2, -1, 0, 0, 1, 2});
|
||||
compareContainers(cpp11_std_array.arrayOutConstRef(), new int[] {-2, -1, 0, 0, 1, 2});
|
||||
compareContainers(cpp11_std_array.arrayOutRef(), new int[] {-2, -1, 0, 0, 1, 2});
|
||||
compareContainers(cpp11_std_array.arrayOutPtr(), new int[] {-2, -1, 0, 0, 1, 2});
|
||||
|
||||
// Check passing arguments
|
||||
ai = cpp11_li_std_array.arrayInVal(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
|
||||
ai = cpp11_std_array.arrayInVal(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
|
||||
compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
|
||||
|
||||
ai = cpp11_li_std_array.arrayInConstRef(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
|
||||
ai = cpp11_std_array.arrayInConstRef(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
|
||||
compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
|
||||
|
||||
ai = new ArrayInt6(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
|
||||
cpp11_li_std_array.arrayInRef(ai);
|
||||
cpp11_std_array.arrayInRef(ai);
|
||||
compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
|
||||
|
||||
ai = new ArrayInt6(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
|
||||
cpp11_li_std_array.arrayInPtr(ai);
|
||||
cpp11_std_array.arrayInPtr(ai);
|
||||
compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
|
||||
|
||||
// fill
|
||||
122
Examples/test-suite/java/cpp11_std_unordered_map_runme.java
Normal file
122
Examples/test-suite/java/cpp11_std_unordered_map_runme.java
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
import cpp11_std_unordered_map.*;
|
||||
|
||||
public class cpp11_std_unordered_map_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp11_std_unordered_map");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkThat(boolean mustBeTrue) throws Throwable {
|
||||
if (!mustBeTrue) {
|
||||
// Index [2], since this function is one hop away from main, and [1] is the current method.
|
||||
throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber());
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) throws Throwable
|
||||
{
|
||||
java.util.AbstractMap<String, Integer> sim = new UnorderedMapStringInt();
|
||||
java.util.AbstractMap<Integer, Integer> iim = new UnorderedMapIntInt();
|
||||
|
||||
checkThat(sim.isEmpty());
|
||||
checkThat(iim.isEmpty());
|
||||
checkThat(sim.size() == 0);
|
||||
checkThat(iim.size() == 0);
|
||||
|
||||
checkThat(sim.get("key") == null);
|
||||
checkThat(iim.get(1) == null);
|
||||
|
||||
checkThat(!sim.containsKey("key"));
|
||||
checkThat(!iim.containsKey(1));
|
||||
|
||||
checkThat(sim.put("key", 2) == null);
|
||||
checkThat(iim.put(1, 2) == null);
|
||||
|
||||
checkThat(sim.size() == 1);
|
||||
checkThat(iim.size() == 1);
|
||||
checkThat(!sim.isEmpty());
|
||||
checkThat(!iim.isEmpty());
|
||||
|
||||
checkThat(sim.get("key") == 2);
|
||||
checkThat(iim.get(1) == 2);
|
||||
|
||||
checkThat(sim.remove("key") == 2);
|
||||
checkThat(iim.remove(1) == 2);
|
||||
|
||||
checkThat(sim.isEmpty());
|
||||
checkThat(iim.isEmpty());
|
||||
checkThat(sim.size() == 0);
|
||||
checkThat(iim.size() == 0);
|
||||
|
||||
checkThat(sim.get("key") == null);
|
||||
checkThat(iim.get(1) == null);
|
||||
|
||||
checkThat(sim.remove("key") == null);
|
||||
checkThat(iim.remove(1) == null);
|
||||
|
||||
checkThat(sim.put("key", 2) == null);
|
||||
checkThat(iim.put(1, 2) == null);
|
||||
|
||||
sim.clear();
|
||||
iim.clear();
|
||||
checkThat(sim.isEmpty());
|
||||
checkThat(iim.isEmpty());
|
||||
|
||||
checkThat(sim.put("key1", 1) == null);
|
||||
checkThat(iim.put(1, 1) == null);
|
||||
checkThat(sim.put("key2", 2) == null);
|
||||
checkThat(iim.put(2, 2) == null);
|
||||
|
||||
checkThat(sim.size() == 2);
|
||||
checkThat(iim.size() == 2);
|
||||
checkThat(sim.get("key1") == 1);
|
||||
checkThat(iim.get(1) == 1);
|
||||
checkThat(sim.get("key2") == 2);
|
||||
checkThat(iim.get(2) == 2);
|
||||
|
||||
checkThat(sim.put("key1", 3) == 1);
|
||||
checkThat(iim.put(1, 3) == 1);
|
||||
|
||||
checkThat(sim.size() == 2);
|
||||
checkThat(iim.size() == 2);
|
||||
checkThat(sim.get("key1") == 3);
|
||||
checkThat(iim.get(1) == 3);
|
||||
|
||||
java.util.Set<java.util.Map.Entry<String, Integer>> sim_es = sim.entrySet();
|
||||
java.util.Map<String, Integer> sim_default = new java.util.HashMap<String, Integer>();
|
||||
sim_default.put("key1", 3);
|
||||
sim_default.put("key2", 2);
|
||||
java.util.Set<java.util.Map.Entry<String, Integer>> sim_es_default = sim_default.entrySet();
|
||||
checkThat(sim_es.size() == sim_es_default.size());
|
||||
for (java.util.Map.Entry<String, Integer> entry : sim_es) {
|
||||
checkThat(sim_es_default.contains(entry));
|
||||
checkThat(sim_default.containsKey(entry.getKey()));
|
||||
checkThat(sim_default.containsValue(entry.getValue()));
|
||||
|
||||
Integer oldValue = entry.getValue();
|
||||
entry.setValue(oldValue + 1);
|
||||
checkThat(sim.get(entry.getKey()) == (oldValue + 1));
|
||||
}
|
||||
|
||||
java.util.Set<java.util.Map.Entry<Integer, Integer>> iim_es = iim.entrySet();
|
||||
java.util.Map<Integer, Integer> iim_default = new java.util.HashMap<Integer, Integer>();
|
||||
iim_default.put(1, 3);
|
||||
iim_default.put(2, 2);
|
||||
java.util.Set<java.util.Map.Entry<Integer, Integer>> iim_es_default = iim_default.entrySet();
|
||||
checkThat(iim_es.size() == iim_es_default.size());
|
||||
for (java.util.Map.Entry<Integer, Integer> entry : iim_es) {
|
||||
checkThat(iim_es_default.contains(entry));
|
||||
checkThat(iim_default.containsKey(entry.getKey()));
|
||||
checkThat(iim_default.containsValue(entry.getValue()));
|
||||
|
||||
Integer oldValue = entry.getValue();
|
||||
entry.setValue(oldValue + 1);
|
||||
checkThat(iim.get(entry.getKey()) == (oldValue + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
75
Examples/test-suite/java/cpp11_std_unordered_set_runme.java
Normal file
75
Examples/test-suite/java/cpp11_std_unordered_set_runme.java
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
import cpp11_std_unordered_set.*;
|
||||
|
||||
public class cpp11_std_unordered_set_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp11_std_unordered_set");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkThat(boolean mustBeTrue) throws Throwable {
|
||||
if (!mustBeTrue) {
|
||||
// Index [2], since this function is one hop away from main, and [1] is the current method.
|
||||
throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber());
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) throws Throwable
|
||||
{
|
||||
java.util.AbstractSet<String> ss = new UnorderedSetString();
|
||||
|
||||
checkThat(ss.isEmpty());
|
||||
checkThat(!ss.contains("key"));
|
||||
checkThat(!ss.remove("key"));
|
||||
|
||||
checkThat(ss.add("key"));
|
||||
checkThat(!ss.add("key"));
|
||||
checkThat(ss.contains("key"));
|
||||
checkThat(ss.remove("key"));
|
||||
checkThat(ss.isEmpty());
|
||||
checkThat(ss.size() == 0);
|
||||
|
||||
checkThat(ss.add("key1"));
|
||||
checkThat(ss.add("key2"));
|
||||
checkThat(ss.add("key3"));
|
||||
checkThat(ss.size() == 3);
|
||||
|
||||
ss.clear();
|
||||
checkThat(ss.isEmpty());
|
||||
checkThat(ss.size() == 0);
|
||||
|
||||
checkThat(ss.addAll(java.util.Arrays.asList("one", "two", "three")));
|
||||
checkThat(ss.size() == 3);
|
||||
checkThat(ss.contains("one"));
|
||||
checkThat(!ss.contains("four"));
|
||||
|
||||
checkThat(ss.containsAll(java.util.Arrays.asList("one", "two", "three")));
|
||||
checkThat(ss.containsAll(java.util.Arrays.asList("one", "two")));
|
||||
checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "four")));
|
||||
checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "three", "four")));
|
||||
|
||||
checkThat(!ss.addAll(java.util.Arrays.asList("one", "two", "three")));
|
||||
|
||||
java.util.Set<String> found = new java.util.HashSet<String>();
|
||||
java.util.Iterator<String> itr = ss.iterator();
|
||||
while (itr.hasNext()) {
|
||||
found.add(itr.next());
|
||||
}
|
||||
|
||||
checkThat(ss.containsAll(found));
|
||||
checkThat(found.containsAll(ss));
|
||||
|
||||
java.util.AbstractSet<String> ss2 = new UnorderedSetString(ss);
|
||||
checkThat(ss2.containsAll(ss));
|
||||
checkThat(ss.containsAll(ss2));
|
||||
|
||||
checkThat(!ss.removeAll(java.util.Arrays.asList("five", "four")));
|
||||
checkThat(ss.removeAll(found));
|
||||
checkThat(ss.isEmpty());
|
||||
checkThat(ss.size() == 0);
|
||||
}
|
||||
}
|
||||
122
Examples/test-suite/java/li_std_map_runme.java
Normal file
122
Examples/test-suite/java/li_std_map_runme.java
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
import li_std_map.*;
|
||||
|
||||
public class li_std_map_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("li_std_map");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkThat(boolean mustBeTrue) throws Throwable {
|
||||
if (!mustBeTrue) {
|
||||
// Index [2], since this function is one hop away from main, and [1] is the current method.
|
||||
throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber());
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) throws Throwable
|
||||
{
|
||||
java.util.AbstractMap<String, Integer> sim = new StringIntMap();
|
||||
java.util.AbstractMap<Integer, Integer> iim = new IntIntMap();
|
||||
|
||||
checkThat(sim.isEmpty());
|
||||
checkThat(iim.isEmpty());
|
||||
checkThat(sim.size() == 0);
|
||||
checkThat(iim.size() == 0);
|
||||
|
||||
checkThat(sim.get("key") == null);
|
||||
checkThat(iim.get(1) == null);
|
||||
|
||||
checkThat(!sim.containsKey("key"));
|
||||
checkThat(!iim.containsKey(1));
|
||||
|
||||
checkThat(sim.put("key", 2) == null);
|
||||
checkThat(iim.put(1, 2) == null);
|
||||
|
||||
checkThat(sim.size() == 1);
|
||||
checkThat(iim.size() == 1);
|
||||
checkThat(!sim.isEmpty());
|
||||
checkThat(!iim.isEmpty());
|
||||
|
||||
checkThat(sim.get("key") == 2);
|
||||
checkThat(iim.get(1) == 2);
|
||||
|
||||
checkThat(sim.remove("key") == 2);
|
||||
checkThat(iim.remove(1) == 2);
|
||||
|
||||
checkThat(sim.isEmpty());
|
||||
checkThat(iim.isEmpty());
|
||||
checkThat(sim.size() == 0);
|
||||
checkThat(iim.size() == 0);
|
||||
|
||||
checkThat(sim.get("key") == null);
|
||||
checkThat(iim.get(1) == null);
|
||||
|
||||
checkThat(sim.remove("key") == null);
|
||||
checkThat(iim.remove(1) == null);
|
||||
|
||||
checkThat(sim.put("key", 2) == null);
|
||||
checkThat(iim.put(1, 2) == null);
|
||||
|
||||
sim.clear();
|
||||
iim.clear();
|
||||
checkThat(sim.isEmpty());
|
||||
checkThat(iim.isEmpty());
|
||||
|
||||
checkThat(sim.put("key1", 1) == null);
|
||||
checkThat(iim.put(1, 1) == null);
|
||||
checkThat(sim.put("key2", 2) == null);
|
||||
checkThat(iim.put(2, 2) == null);
|
||||
|
||||
checkThat(sim.size() == 2);
|
||||
checkThat(iim.size() == 2);
|
||||
checkThat(sim.get("key1") == 1);
|
||||
checkThat(iim.get(1) == 1);
|
||||
checkThat(sim.get("key2") == 2);
|
||||
checkThat(iim.get(2) == 2);
|
||||
|
||||
checkThat(sim.put("key1", 3) == 1);
|
||||
checkThat(iim.put(1, 3) == 1);
|
||||
|
||||
checkThat(sim.size() == 2);
|
||||
checkThat(iim.size() == 2);
|
||||
checkThat(sim.get("key1") == 3);
|
||||
checkThat(iim.get(1) == 3);
|
||||
|
||||
java.util.Set<java.util.Map.Entry<String, Integer>> sim_es = sim.entrySet();
|
||||
java.util.Map<String, Integer> sim_default = new java.util.HashMap<String, Integer>();
|
||||
sim_default.put("key1", 3);
|
||||
sim_default.put("key2", 2);
|
||||
java.util.Set<java.util.Map.Entry<String, Integer>> sim_es_default = sim_default.entrySet();
|
||||
checkThat(sim_es.size() == sim_es_default.size());
|
||||
for (java.util.Map.Entry<String, Integer> entry : sim_es) {
|
||||
checkThat(sim_es_default.contains(entry));
|
||||
checkThat(sim_default.containsKey(entry.getKey()));
|
||||
checkThat(sim_default.containsValue(entry.getValue()));
|
||||
|
||||
Integer oldValue = entry.getValue();
|
||||
entry.setValue(oldValue + 1);
|
||||
checkThat(sim.get(entry.getKey()) == (oldValue + 1));
|
||||
}
|
||||
|
||||
java.util.Set<java.util.Map.Entry<Integer, Integer>> iim_es = iim.entrySet();
|
||||
java.util.Map<Integer, Integer> iim_default = new java.util.HashMap<Integer, Integer>();
|
||||
iim_default.put(1, 3);
|
||||
iim_default.put(2, 2);
|
||||
java.util.Set<java.util.Map.Entry<Integer, Integer>> iim_es_default = iim_default.entrySet();
|
||||
checkThat(iim_es.size() == iim_es_default.size());
|
||||
for (java.util.Map.Entry<Integer, Integer> entry : iim_es) {
|
||||
checkThat(iim_es_default.contains(entry));
|
||||
checkThat(iim_default.containsKey(entry.getKey()));
|
||||
checkThat(iim_default.containsValue(entry.getValue()));
|
||||
|
||||
Integer oldValue = entry.getValue();
|
||||
entry.setValue(oldValue + 1);
|
||||
checkThat(iim.get(entry.getKey()) == (oldValue + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
75
Examples/test-suite/java/li_std_set_runme.java
Normal file
75
Examples/test-suite/java/li_std_set_runme.java
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
import li_std_set.*;
|
||||
|
||||
public class li_std_set_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("li_std_set");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkThat(boolean mustBeTrue) throws Throwable {
|
||||
if (!mustBeTrue) {
|
||||
// Index [2], since this function is one hop away from main, and [1] is the current method.
|
||||
throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber());
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) throws Throwable
|
||||
{
|
||||
java.util.AbstractSet<String> ss = new StringSet();
|
||||
|
||||
checkThat(ss.isEmpty());
|
||||
checkThat(!ss.contains("key"));
|
||||
checkThat(!ss.remove("key"));
|
||||
|
||||
checkThat(ss.add("key"));
|
||||
checkThat(!ss.add("key"));
|
||||
checkThat(ss.contains("key"));
|
||||
checkThat(ss.remove("key"));
|
||||
checkThat(ss.isEmpty());
|
||||
checkThat(ss.size() == 0);
|
||||
|
||||
checkThat(ss.add("key1"));
|
||||
checkThat(ss.add("key2"));
|
||||
checkThat(ss.add("key3"));
|
||||
checkThat(ss.size() == 3);
|
||||
|
||||
ss.clear();
|
||||
checkThat(ss.isEmpty());
|
||||
checkThat(ss.size() == 0);
|
||||
|
||||
checkThat(ss.addAll(java.util.Arrays.asList("one", "two", "three")));
|
||||
checkThat(ss.size() == 3);
|
||||
checkThat(ss.contains("one"));
|
||||
checkThat(!ss.contains("four"));
|
||||
|
||||
checkThat(ss.containsAll(java.util.Arrays.asList("one", "two", "three")));
|
||||
checkThat(ss.containsAll(java.util.Arrays.asList("one", "two")));
|
||||
checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "four")));
|
||||
checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "three", "four")));
|
||||
|
||||
checkThat(!ss.addAll(java.util.Arrays.asList("one", "two", "three")));
|
||||
|
||||
java.util.Set<String> found = new java.util.HashSet<String>();
|
||||
java.util.Iterator<String> itr = ss.iterator();
|
||||
while (itr.hasNext()) {
|
||||
found.add(itr.next());
|
||||
}
|
||||
|
||||
checkThat(ss.containsAll(found));
|
||||
checkThat(found.containsAll(ss));
|
||||
|
||||
java.util.AbstractSet<String> ss2 = new StringSet(ss);
|
||||
checkThat(ss2.containsAll(ss));
|
||||
checkThat(ss.containsAll(ss2));
|
||||
|
||||
checkThat(!ss.removeAll(java.util.Arrays.asList("five", "four")));
|
||||
checkThat(ss.removeAll(found));
|
||||
checkThat(ss.isEmpty());
|
||||
checkThat(ss.size() == 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* a test of set containers.
|
||||
* a test of set containers.
|
||||
* Languages should define swig::LANGUAGE_OBJ to be
|
||||
* an entity of their native pointer type which can be
|
||||
* included in a STL container.
|
||||
|
|
@ -13,22 +13,23 @@
|
|||
|
||||
%include <std_string.i>
|
||||
%include <std_set.i>
|
||||
%include <std_multiset.i>
|
||||
%include <std_vector.i>
|
||||
|
||||
%template(set_string) std::set<std::string>;
|
||||
%template(set_int) std::multiset<int>;
|
||||
|
||||
|
||||
%template(v_int) std::vector<int>;
|
||||
|
||||
|
||||
|
||||
// Use language macros since Java doesn't have multiset support (yet)
|
||||
// and uses different naming conventions.
|
||||
#if defined(SWIGRUBY) || defined(SWIGPYTHON)
|
||||
%include <std_multiset.i>
|
||||
%template(set_int) std::multiset<int>;
|
||||
%template(v_int) std::vector<int>;
|
||||
%template(set_string) std::set<std::string>;
|
||||
#elif defined(SWIGJAVA)
|
||||
%template(StringSet) std::set<std::string>;
|
||||
#endif
|
||||
|
||||
#if defined(SWIGRUBY)
|
||||
%template(LanguageSet) std::set<swig::LANGUAGE_OBJ>;
|
||||
%template(LanguageSet) std::set<swig::LANGUAGE_OBJ>;
|
||||
#endif
|
||||
|
||||
#if defined(SWIGPYTHON)
|
||||
%template(pyset) std::set<swig::SwigPtr_PyObject>;
|
||||
%template(pyset) std::set<swig::SwigPtr_PyObject>;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ std::vector<std::string> vecStr(std::vector<std::string> v) {
|
|||
double *makeDoublePtr(double v) { return new double(v); }
|
||||
int extractInt(int *p) { return *p; }
|
||||
short extractConstShort(const short *p) { return *p; }
|
||||
short extractConstShort2(std::vector<const short *>::value_type p) { return *p; }
|
||||
%}
|
||||
|
||||
%template(pyvector) std::vector<swig::SwigPtr_PyObject>;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,19 @@ using namespace std;
|
|||
int* makeIntPtr(int v) {
|
||||
return new int(v);
|
||||
}
|
||||
std::vector<int *>::value_type makeIntPtr2(int v) {
|
||||
return new int(v);
|
||||
}
|
||||
int getIntValue(int *p) {
|
||||
return *p;
|
||||
}
|
||||
int getIntValue2(std::vector<int *>::const_reference p) {
|
||||
return *p;
|
||||
}
|
||||
int getIntValue3(std::vector<int *>::reference p) {
|
||||
return *p;
|
||||
}
|
||||
|
||||
double* makeDoublePtr(double v) {
|
||||
return new double(v);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from cpp11_li_std_array import *
|
||||
from cpp11_std_array import *
|
||||
import sys
|
||||
|
||||
|
||||
|
|
@ -173,3 +173,11 @@ if extractConstShort(vcs[0]) != 111:
|
|||
|
||||
if extractConstShort(vcs[1]) != 222:
|
||||
raise RuntimeError
|
||||
|
||||
for p in vcs[0:1]:
|
||||
if extractConstShort2(p) != 111:
|
||||
raise RuntimeError
|
||||
|
||||
for p in vcs[1:2]:
|
||||
if extractConstShort2(p) != 222:
|
||||
raise RuntimeError
|
||||
|
|
|
|||
|
|
@ -4,12 +4,20 @@ def check(val1, val2):
|
|||
if val1 != val2:
|
||||
raise RuntimeError("Values are not the same %s %s" % (val1, val2))
|
||||
ip1 = makeIntPtr(11)
|
||||
ip2 = makeIntPtr(22)
|
||||
ip2 = makeIntPtr2(22)
|
||||
|
||||
vi = IntPtrVector((ip1, ip2))
|
||||
check(getValueFromVector(vi, 0), 11)
|
||||
check(getValueFromVector(vi, 1), 22)
|
||||
|
||||
check(getIntValue(vi[0]), 11)
|
||||
check(getIntValue(vi[1]), 22)
|
||||
check(getIntValue2(vi[0]), 11)
|
||||
check(getIntValue2(vi[1]), 22)
|
||||
|
||||
ipp = makeIntPtrPtr(vi[0])
|
||||
check(getIntValue3(ipp), 11) # Note: getIntValue3 takes int**
|
||||
|
||||
vA = APtrVector([makeA(33), makeA(34)])
|
||||
check(getVectorValueA(vA, 0), 33)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@
|
|||
|
||||
require 'swig_assert'
|
||||
|
||||
require 'cpp11_li_std_array'
|
||||
require 'cpp11_std_array'
|
||||
|
||||
include Cpp11_li_std_array
|
||||
include Cpp11_std_array
|
||||
|
||||
|
||||
def failed(a, b, msg)
|
||||
Loading…
Add table
Add a link
Reference in a new issue