~ubuntu-branches/debian/squeeze/aptitude/squeeze

« back to all changes in this revision

Viewing changes to tests/test_misc.cc

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Burrows
  • Date: 2007-03-13 20:49:58 UTC
  • Revision ID: james.westby@ubuntu.com-20070313204958-l7040344gthwxlvj
Tags: 0.4.4-4
In addition to the bugfix for ssprintf, the last release included
a new test case to ensure that the bug did not recur.  As it turned
out, this test case revealed that both the old and the new code
were buggy on amd64!  vssnprintf now handles its variable argument
list properly, using va_copy in case it has to access the list a
second time. (Closes: #414617)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// Miscellaneous tests.
2
2
//
3
 
//   Copyright (C) 2005 Daniel Burrows
 
3
//   Copyright (C) 2005, 2007 Daniel Burrows
4
4
//
5
5
//   This program is free software; you can redistribute it and/or
6
6
//   modify it under the terms of the GNU General Public License as
27
27
 
28
28
  CPPUNIT_TEST(testStripWS);
29
29
  CPPUNIT_TEST(testOrderlessLt);
 
30
  CPPUNIT_TEST(test_ssprintf);
30
31
 
31
32
  CPPUNIT_TEST_SUITE_END();
32
33
private:
94
95
    CPPUNIT_ASSERT(!cmp(d, c));
95
96
    CPPUNIT_ASSERT(!cmp(e, d));
96
97
  }
 
98
 
 
99
  void test_ssprintf()
 
100
  {
 
101
    // Test that inserting very long strings via ssprintf actually works.
 
102
    std::string horriblelongthing = "abcdefghijklmnopqrstuvwxyz";
 
103
    while(horriblelongthing.size() < 4096)
 
104
      horriblelongthing += horriblelongthing;
 
105
 
 
106
    CPPUNIT_ASSERT_EQUAL(horriblelongthing + " 20", ssprintf("%s %d", horriblelongthing.c_str(), 20));
 
107
  }
97
108
};
98
109
 
99
110
CPPUNIT_TEST_SUITE_REGISTRATION(MiscTest);