Skip to content

Commit 47b5bd0

Browse files
committed
Add missing files of TestDeduplication unit test
1 parent 7d6f09b commit 47b5bd0

File tree

5 files changed

+74
-0
lines changed

5 files changed

+74
-0
lines changed

test/TestDeduplication/A.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <iostream>
2+
3+
struct A{
4+
const char* f() { return "const char* f()"; }
5+
const char* f() const { return "const char* f() const"; }
6+
7+
const char* g(int){ return "const char* g(int)"; }
8+
const char* g(int64_t){ return "const char* g(int64_t)"; }
9+
10+
11+
static const char* h(int){ return "static const char* h(int)"; }
12+
static const char* h(int64_t){ return "static const char* h(int64_t)"; }
13+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cmake_minimum_required(VERSION 3.12)
2+
3+
project(TestDeduplication)
4+
5+
set(WRAPPER_EXTRA_SRCS)
6+
7+
# All of the real work is done in the lower level CMake file
8+
include(../WrapitTestSetup.cmake)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module_name="TestDeduplication"
2+
uuid = "68e5aff2-27ba-4614-8412-37a57b7bbfca"
3+
4+
input = [ "A.h" ]
5+
6+
include_dirs = [ "." ]
7+
8+
cxx-std = "c++17"
9+
10+
auto_veto = false
11+
12+
export = "all"
13+
14+
# all generated code in a single file:
15+
n_classes_per_file = 0
16+
17+
cxx2cxx_type_map = [ "int -> int64_t" ]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env julia
2+
3+
TEST_SCRIPT="runTestDeduplication.jl"
4+
5+
#number of cores to use for code compilation
6+
ncores=Sys.CPU_THREADS
7+
8+
# Generate the wrapper and build the shared library:
9+
run(`cmake -B build .`)
10+
run(`cmake --build build -j $ncores`)
11+
12+
# Execute the test
13+
include(TEST_SCRIPT)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Test
2+
using Serialization
3+
4+
import Pkg
5+
Pkg.activate("$(@__DIR__)/build")
6+
Pkg.develop(path="$(@__DIR__)/build/TestDeduplication")
7+
using TestDeduplication
8+
9+
function runtest()
10+
@testset "Deduplication" begin
11+
a = A()
12+
@test f(a) == "const char* f()"
13+
@test g(a,1) == "const char* g(int64_t)"
14+
@test A!h(1) == "static const char* h(int64_t)"
15+
end
16+
end
17+
18+
if "-s" in ARGS #Serialize mode
19+
Test.TESTSET_PRINT_ENABLE[] = false
20+
serialize(stdout, runtest())
21+
else
22+
runtest()
23+
end

0 commit comments

Comments
 (0)