complete my code

profilecorrected
Forassignment04.docx

For assignment 04, as a lot of you have already discovered and noted, the unit tests for the paging simulator will probably not pass for you as they are currently given.  There are a few places where we generate a random sequence of page references (using the generateRandomPageStream() function).  So even if you get all of the other unit tests to pass, you may be seeing the following fail, the tests on line 55, 59, 330 and 443:

```

./test --use-colour yes

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test is a Catch v2.12.2 host application. Run with -? for options

------------------------------------------------------------------------------- Test PagingSystem basic construction and page stream creation ------------------------------------------------------------------------------- assg04-tests.cpp:28 ...............................................................................

assg04-tests.cpp:55: FAILED: CHECK( sim.pageStreamToString() == "[ 6 ]" ) with expansion: "[ 7 ]" == "[ 6 ]"

assg04-tests.cpp:59: FAILED: CHECK( sim.pageStreamToString() == "[ 76, 1, 70, 57, 84, 80, 17, 45, 10, 70, 10, 51, 72, 100, 37, 26, 89, 13, 52, 77 ]" ) with expansion: "[ 67, 41, 82, 42, 13, 59, 22, 41, 36, 44, 75, 44, 18, 5, 97, 63, 93, 49, 99, 60 ]" == "[ 76, 1, 70, 57, 84, 80, 17, 45, 10, 70, 10, 51, 72, 100, 37, 26, 89, 13, 52, 77 ]"

------------------------------------------------------------------------------- Test full fifo simulation execution ------------------------------------------------------------------------------- assg04-tests.cpp:303 ...............................................................................

assg04-tests.cpp:330: FAILED: CHECK( sim.memoryToString() == "[ 68, 82, 41 ]" ) with expansion: "[ 21, 56, 70 ]" == "[ 68, 82, 41 ]"

------------------------------------------------------------------------------- Test full clock simulation execution ------------------------------------------------------------------------------- assg04-tests.cpp:416 ...............................................................................

assg04-tests.cpp:443: FAILED: CHECK( sim.memoryToString() == "[ 53, 82, 41, 68 ]" ) with expansion: "[ 56, 84, 21, 70 ]" == "[ 53, 82, 41, 68 ]"

=============================================================================== test cases: 7 | 4 passed | 3 failed assertions: 129 | 125 passed | 4 failed

make: *** [../../include/Makefile.inc:65: unit-tests] Error 4

```

These all fail because I forgot to check/update the expected outputs for the tests.  I have updated the assg04-tests.cpp file to have the correct expected output for our DevBox random number generator.  I have attached the corrected unit tests file to this announcement, and I have also commited and pushed these corrections to our class repository.  So you can either download this file and replace it by hand, or do a

```

$ git pull

```

in your repository to get the corrections.

The way this test was supposed to work is that, we generate a random sequence of pages using the random number generator.  But we set the seed for the random number generator by passing in 42 (the third parameter) as the same seed each time.  So bacisally, if you run the random number generator with the same seed, you should expect to get the same sequence of (randomly generated) pages back.  But because of differences in which version of the C/C++ libraries you use, this sequence might be different for different compilers/environments.  But if we are all using the exact same development environment, then we can set up unit tests with randomly generated sequences like this.

In short, you can either just ignore these 4 failing tests, if they are the only ones that are failing  then you probably have implemented the paging system functions correctly.  Or you can do a git pull or otherwise replace your tests with the correct set of expected tests I give you.