SamFileTest.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "SamFileTest.h"
00019 #include "SamFile.h"
00020
00021 void testSamFile()
00022 {
00023 SamFileHeader header;
00024
00025
00026 SamFile samInConstructorReadDefault("testFiles/testSam.sam",
00027 SamFile::READ,
00028 ErrorHandler::RETURN);
00029 assert(samInConstructorReadDefault.WriteHeader(header) == false);
00030 assert(samInConstructorReadDefault.ReadHeader(header) == true);
00031
00032
00033 SamFile samInConstructorWrite("results/newWrite.sam", SamFile::WRITE,
00034 ErrorHandler::RETURN);
00035 assert(samInConstructorWrite.ReadHeader(header) == false);
00036 assert(samInConstructorWrite.WriteHeader(header) == true);
00037
00038
00039 SamFile samInConstructorRead("testFiles/testSam.sam", SamFile::READ);
00040 bool caughtException = false;
00041 try
00042 {
00043 assert(samInConstructorRead.WriteHeader(header) == false);
00044 }
00045 catch (std::exception& e)
00046 {
00047 caughtException = true;
00048 }
00049 assert(caughtException);
00050 assert(samInConstructorRead.ReadHeader(header) == true);
00051
00052
00053 SamFileWriter samWriteConstructor("results/newWrite1.sam");
00054 caughtException = false;
00055 try
00056 {
00057 assert(samWriteConstructor.ReadHeader(header) == false);
00058 }
00059 catch (std::exception& e)
00060 {
00061 caughtException = true;
00062 }
00063 assert(caughtException);
00064 assert(samWriteConstructor.WriteHeader(header) == true);
00065
00066
00067 SamFileReader samReadConstructor("testFiles/testSam.sam");
00068 caughtException = false;
00069 try
00070 {
00071 assert(samReadConstructor.WriteHeader(header) == false);
00072 }
00073 catch (std::exception& e)
00074 {
00075 caughtException = true;
00076 }
00077 assert(caughtException);
00078 assert(samReadConstructor.ReadHeader(header) == true);
00079 }