예제 #1
0
파일: CPUTest.cs 프로젝트: zieredet/i10CPU
        public void AddLargeNumTest()
        {
            CPU target = new CPU();
            string[] codelines = new string[] {
                // 2000 + 100*250
                "LOAD R0,2000",
                "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250",
                "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250",
                "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250",
                "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250",
                "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250",
                "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250",
                "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250",
                "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250",
                "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250",
                "ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250","ADD 250"
            };
            int startAddress = 0;
            target.LoadMemory(codelines, startAddress);

            target.Run(startAddress);
            Assert.AreEqual(27000, target.GetRegisterValue(0));
        }
예제 #2
0
파일: ADDTest.cs 프로젝트: zieredet/i10CPU
 //
 //You can use the following additional attributes as you write your tests:
 //
 //Use ClassInitialize to run code before running the first test in the class
 //[ClassInitialize()]
 //public static void MyClassInitialize(TestContext testContext)
 //{
 //}
 //
 //Use ClassCleanup to run code after all tests in a class have run
 //[ClassCleanup()]
 //public static void MyClassCleanup()
 //{
 //}
 //
 //Use TestInitialize to run code before running each test
 //[TestInitialize()]
 public void MyTestInitialize()
 {
     CPU cpu = new CPU();
 }
예제 #3
0
파일: CPUTest.cs 프로젝트: zieredet/i10CPU
        public void AddNegNumTest()
        {
            CPU target = new CPU();
            string[] codelines = new string[] {
                "LOAD R0,-500",
                "ADD 250"
            };
            int startAddress = 0;
            target.LoadMemory(codelines, startAddress);

            Assert.AreNotEqual(0, target.Memory.GetWord(0).UValue);
            Assert.AreNotEqual(0, target.Memory.GetWord(2).UValue);
            Assert.AreEqual(0, target.Memory.GetWord(4).UValue);

            target.Run(startAddress);
            Assert.AreEqual(-250, target.GetRegisterValue(0));
        }
예제 #4
0
파일: CPUTest.cs 프로젝트: zieredet/i10CPU
 public void ReadPgmTestFileNotFound()
 {
     CPU target = new CPU();
     string fullFilename = "FileNotExist.cpu";
     string[] actual;
     try
     {
         actual = target.ReadPgm(fullFilename);
         Assert.Fail("fileNotFoundException exptected");
     }
     catch (FileNotFoundException)
     {
         Assert.IsTrue(true);
     }
 }
예제 #5
0
파일: CPUTest.cs 프로젝트: zieredet/i10CPU
 public void ReadPgmTestFileExtNotSupported()
 {
     CPU target = new CPU();
     string fullFilename = "FileNotExist.txt";
     string[] actual;
     try
     {
         actual = target.ReadPgm(fullFilename);
         Assert.Fail("FileExtention not supported");
     }
     catch (CPUException)
     {
         Assert.IsTrue(true);
     }
 }
예제 #6
0
파일: CPUTest.cs 프로젝트: zieredet/i10CPU
        public void LoadMemoryTest()
        {
            CPU target = new CPU();

            string[] codelines = new string[] {
                "ADD R1",
                "ADD 500",
                "ADD R2"
            };
            int startAddress = 0;
            target.LoadMemory(codelines, startAddress);

            Assert.AreNotEqual(0, target.Memory.GetWord(0).UValue);  // ADD R1
            Assert.AreNotEqual(0, target.Memory.GetWord(2).UValue);  // ADD 500
            Assert.AreNotEqual(0, target.Memory.GetWord(4).UValue);  // ADD R2
            Assert.AreEqual(0, target.Memory.GetWord(6).UValue);
        }