Unit testing

closed account (GL1Rko23)
I am trying to test my string <= and this is my test:

// String Test Program
//
// Tests: Less then or equal
//

#include "string.h"

#include <cassert>

//===========================================================================
int main ()
{
{
//------------------------------------------------------
// Setup fixture
string a("abc");
string b("abc");

// Test
20: result = (a =< b);
// Verify
assert(true);

}
}

I have an error on line 20 saying 'result' was not declared in this scope but it looks right to me.
Actually your error is right. You don't declare it. You need to do this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// String Test Program
//
// Tests: Less then or equal
//

#include "string.h"

#include <cassert>

//===========================================================================
int main ()
{
  {
  //------------------------------------------------------
  // Setup fixture
  string a("abc");
  string b("abc");

  // Test
  bool result = (a =< b); // result was not declared as a type before.
  // Verify
  assert(true);

  }
}
closed account (GL1Rko23)
Ooof, did not even think of that, but you are right. Thank you.
Topic archived. No new replies allowed.