-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMismatchTests.cpp
95 lines (80 loc) · 2.09 KB
/
MismatchTests.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#pragma unmanaged
#pragma comment(lib, "spasm.lib")
#include "..\SPASM\pass_one.h"
#include "..\SPASM\pass_two.h"
#include "..\SPASM\parser.h"
#include "..\SPASM\spasm.h"
#include "..\SPASM\errors.h"
#include "..\SPASM\storage.h"
#include <stdio.h>
#include <direct.h>
//#include <string>
#pragma managed
using namespace System;
using namespace System::Text;
using namespace System::Collections::Generic;
using namespace Microsoft::VisualStudio::TestTools::UnitTesting;
using namespace std;
namespace SPASMTestsVS2008
{
[TestClass]
public ref class MismatchTests
{
public:
[TestInitialize]
void Init()
{
}
[TestCleanup]
void Cleanup()
{
}
// Run the file, return the error code
int RunTest(const char *file_name)
{
ClearSPASMErrorSessions();
char full_filename[256] = "..\\..\\..\\..\\..\\Tests\\SPASMTests\\";
strcat_s(full_filename, file_name);
OutputDebugString(TEXT("Start\n"));
output_contents = (unsigned char *) malloc(output_buf_size);
init_storage();
curr_input_file = _strdup(full_filename);
output_filename = "output.bin";
mode = MODE_LIST;
run_assembly();
mode = 0;
free_storage();
free(output_contents);
return (int) GetLastSPASMError();
}
[TestMethod]
void Mismatch1()
{
RunTest("mismatch1.z80");
Assert::AreEqual(SPASM_ERR_UNMATCHED_IF, (int) GetLastSPASMError(), "Wrong error code");
Assert::AreEqual(1, GetLastSPASMErrorLine(), "Wrong error line");
}
[TestMethod]
void Mismatch2()
{
RunTest("mismatch2.z80");
Assert::AreEqual(SPASM_ERR_UNMATCHED_IF, (int) GetLastSPASMError(), "Wrong error code");
Assert::AreEqual(5, GetLastSPASMErrorLine(), "Wrong error line");
}
[TestMethod]
void Mismatch3()
{
Assert::AreEqual(SPASM_ERR_UNMATCHED_IF, RunTest("mismatch3.z80"));
}
[TestMethod]
void Mismatch4()
{
Assert::AreEqual(SPASM_ERR_UNMATCHED_IF, RunTest("mismatch4.z80"));
}
[TestMethod]
void Mismatch5()
{
Assert::AreEqual(SPASM_ERR_SUCCESS, RunTest("mismatch5.z80"));
}
};
}