-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RFCT move crc computation to records.Crc, add test
- Loading branch information
Showing
5 changed files
with
99 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
|
||
from fitparse.records import Crc | ||
|
||
if sys.version_info >= (2, 7): | ||
import unittest | ||
else: | ||
import unittest2 as unittest | ||
|
||
|
||
class RecordsTestCase(unittest.TestCase): | ||
def test_crc(self): | ||
crc = Crc() | ||
self.assertEqual(0, crc.value) | ||
crc.update(b'\x0e\x10\x98\x00(\x00\x00\x00.FIT') | ||
self.assertEqual(0xace7, crc.value) | ||
# 0 must not change the crc | ||
crc.update(0) | ||
self.assertEqual(0xace7, crc.value) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |