Skip to content

Commit 5cf2e32

Browse files
committed
Add cross2 test.
1 parent 6fcb81b commit 5cf2e32

4 files changed

Lines changed: 53 additions & 0 deletions

File tree

test/build/cross2/exceptions.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "exceptions.h"
2+
3+
namespace sw
4+
{
5+
6+
RuntimeError::RuntimeError(const std::string &msg)
7+
: std::runtime_error("")
8+
{
9+
}
10+
11+
} // namespace sw

test/build/cross2/exceptions.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
3+
#include <stdexcept>
4+
#include <string>
5+
6+
namespace sw
7+
{
8+
9+
struct API RuntimeError : std::runtime_error
10+
{
11+
RuntimeError(const std::string &msg);
12+
};
13+
14+
}

test/build/cross2/main.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "exceptions.h"
2+
3+
#include <iostream>
4+
5+
void f()
6+
{
7+
try { throw 5; }
8+
catch (int) { std::cout << "int\n"; }
9+
try { throw sw::RuntimeError(""); }
10+
catch (sw::RuntimeError) { std::cout << "sw::RuntimeError\n"; }
11+
}
12+
13+
int main()
14+
{
15+
f();
16+
return 0;
17+
}

test/build/cross2/sw.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
void build(Solution &s)
2+
{
3+
auto &lib = s.addStaticLibrary("lib");
4+
lib.ApiName = "API";
5+
lib += "exceptions.h";
6+
lib += "exceptions.cpp";
7+
8+
auto &t = s.addExecutable("test");
9+
t += "main.cpp";
10+
t += lib;
11+
}

0 commit comments

Comments
 (0)