コード例 #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);
        }