MCPcopy Create free account
hub / github.com/audacity/audacity / testCorrectDataWritten

Method testCorrectDataWritten

tests/SimpleBlockFileTest.cpp:108–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106 }
107
108 void testCorrectDataWritten() {
109 // use libsndfile to read back the whole blockfile, make sure it matches
110 // the data we initially wrote
111 std::cout << "\tVerifying that we wrote what we think we wrote..." << std::flush;
112
113 SF_INFO info1, info2, info3;
114 memset(&info1, 0, sizeof(info1));
115 memset(&info2, 0, sizeof(info2));
116 memset(&info3, 0, sizeof(info3));
117
118 SNDFILE *int16sf = sf_open(int16BlockFile->GetFileName().GetFullPath(), SFM_READ, &info1);
119 SNDFILE *int24sf = sf_open(int24BlockFile->GetFileName().GetFullPath(), SFM_READ, &info2);
120 SNDFILE *floatsf = sf_open(floatBlockFile->GetFileName().GetFullPath(), SFM_READ, &info3);
121
122 // First do a read of the entire block
123 short int16buf[dataLen];
124 int int24buf[dataLen];
125 float floatbuf[dataLen];
126
127 sf_read_short(int16sf, int16buf, dataLen);
128 sf_read_int (int24sf, int24buf, dataLen);
129 sf_read_float(floatsf, floatbuf, dataLen);
130
131 AssertBuffersEqual(int16buf, int16Data, dataLen);
132 AssertBuffersEqual(floatbuf, floatData, dataLen);
133
134 // for the 24-bit buffer, libsndfile gives the 24 bits to us in the 3 most significant
135 // byts of a 32-bit int. So we need to shift them right 8 to get back our 24-bit data.
136 for( int i = 0; i < dataLen; i++ )
137 int24buf[i] = int24buf[i] >> 8;
138 AssertBuffersEqual(int24buf, int24Data, dataLen);
139
140 sf_close(int16sf);
141 sf_close(int24sf);
142 sf_close(floatsf);
143
144 std::cout << "OK\n";
145 }
146
147 void testReads() {
148 // Now use the blockfile's method to read data and compare it to what we originally wrote

Callers 1

mainFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected