~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to testknit.py

  • Committer: Martin Pool
  • Date: 2005-06-27 03:19:33 UTC
  • mto: This revision was merged to the branch mainline in revision 852.
  • Revision ID: mbp@sourcefrog.net-20050627031933-8c7311c41a7148d3
Add stubbed-out TestSkipped

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005 by Canonical Ltd
 
2
 
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
 
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
 
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
 
 
18
 
 
19
 
 
20
"""test case for knit/weave algorithm"""
 
21
 
 
22
 
 
23
from testsweet import TestBase
 
24
from knit import Knit
 
25
 
 
26
 
 
27
# texts for use in testing
 
28
TEXT_0 = ["Hello world"]
 
29
TEXT_1 = ["Hello world",
 
30
          "A second line"]
 
31
 
 
32
 
 
33
class Easy(TestBase):
 
34
    def runTest(self):
 
35
        k = Knit()
 
36
 
 
37
 
 
38
class StoreText(TestBase):
 
39
    """Store and retrieve a simple text."""
 
40
    def runTest(self):
 
41
        k = Knit()
 
42
        idx = k.add(TEXT_0)
 
43
        self.assertEqual(k.get(idx), TEXT_0)
 
44
        self.assertEqual(idx, 0)
 
45
 
 
46
 
 
47
 
 
48
class AnnotateOne(TestBase):
 
49
    def runTest(self):
 
50
        k = Knit()
 
51
        k.add(TEXT_0)
 
52
        self.assertEqual(k.annotate(0),
 
53
                         [(0, TEXT_0[0])])
 
54
 
 
55
 
 
56
class StoreTwo(TestBase):
 
57
    def runTest(self):
 
58
        k = Knit()
 
59
 
 
60
        idx = k.add(TEXT_0)
 
61
        self.assertEqual(idx, 0)
 
62
 
 
63
        idx = k.add(TEXT_1)
 
64
        self.assertEqual(idx, 1)
 
65
 
 
66
        self.assertEqual(k.get(0), TEXT_0)
 
67
        self.assertEqual(k.get(1), TEXT_1)
 
68
 
 
69
 
 
70
def testknit():
 
71
    import testsweet
 
72
    from unittest import TestSuite, TestLoader
 
73
    import testknit
 
74
 
 
75
    tl = TestLoader()
 
76
    suite = TestSuite()
 
77
    suite.addTest(tl.loadTestsFromModule(testknit))
 
78
    
 
79
    return testsweet.run_suite(suite)
 
80
 
 
81
 
 
82
if __name__ == '__main__':
 
83
    import sys
 
84
    sys.exit(testknit())
 
85