PageRenderTime 56ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/WabbitStudio/Tests/SPASMTests/MismatchTests.cpp

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