File: t.composite.h

package info (click to toggle)
mimetic 0.9.6-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,656 kB
  • ctags: 1,746
  • sloc: cpp: 11,240; sh: 9,080; makefile: 115
file content (71 lines) | stat: -rw-r--r-- 1,671 bytes parent folder | download | duplicates (10)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef _T_COMPOSITE_H_
#define _T_COMPOSITE_H_
#include <sstream>
#include <iterator>
#include <algorithm>
#include <string>
#include <cctype>
#include <mimetic/codec/codec.h>
#include "cutee.h"


namespace mimetic 
{

class TEST_CLASS( test_composite )
{
    static const char* test[][2];
    std::string uppercase(const std::string& s)
    {
        std::string r;
        for(uint i=0;i<s.length();i++)
            r+=toupper(s[i]);
        return r;
    }
    std::string lowercase(const std::string& s)
    {
        std::string r;
        for(uint i=0;i<s.length();i++)
            r+=tolower(s[i]);
        return r;
    }
public:
    void TEST_FUNCTION( testBase64ToUpperCase )
    {
        int i = 0;
        while(test[i][0] != 0)
        {
            std::string src = test[i][0];
            std::string exp = uppercase(test[i][1]);
            std::string got;
            Base64::Encoder base64;
            ToUpperCase tuc;
            encode(src.begin(), src.end(),
                base64 | tuc,
                std::back_inserter<std::string>(got));
            TEST_ASSERT_EQUALS_P( exp, got);
            i++;
        }
    }
    void TEST_FUNCTION( testBase64ToLowerCase )
    {
        int i = 0;
        while(test[i][0] != 0)
        {
            std::string src = test[i][0];
            std::string exp = lowercase(test[i][1]);
            std::string got;
            Base64::Encoder base64;
            ToLowerCase tlc;
            encode(src.begin(), src.end(),
                base64 | tlc,
                std::back_inserter<std::string>(got));
            TEST_ASSERT_EQUALS_P( exp, got);
            i++;
        }
    }
};

}

#endif