about summary refs log tree commit diff stats
path: root/themes/mono
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-11-09 23:31:21 +0000
committerJames Booth <boothj5@gmail.com>2015-11-09 23:31:21 +0000
commitbee27f47736d5d16500bb83e7ae9b5cd80cd4b26 (patch)
treeabc1ed194fcc406ac7ecff21e0fe93ed52db026e /themes/mono
parent4cbfb888141cf060608f213499672e0b2c56f331 (diff)
downloadprofani-tty-bee27f47736d5d16500bb83e7ae9b5cd80cd4b26.tar.gz
Added /tls cert to show current certificate fingerprint
Diffstat (limited to 'themes/mono')
0 files changed, 0 insertions, 0 deletions
tests/helpers.c?id=66f9a6b7219391b2c8bee5967f5ef7e223fd5d23'>^
a4cadf78 ^
25a6252a ^
5f25d993 ^
a2726b6a ^

5f25d993 ^

a3a73cf0 ^
5f25d993 ^

6ef1174b ^

a2726b6a ^

6ef1174b ^




a2726b6a ^

6ef1174b ^

a3a73cf0 ^
6ef1174b ^

6ef1174b ^
5f25d993 ^
a2726b6a ^

6ef1174b ^




a2726b6a ^

6ef1174b ^

a2726b6a ^
cb590dd8 ^
10ca3e8c ^
cb590dd8 ^
9b5cdf8e ^
5f25d993 ^

a2726b6a ^

5f25d993 ^
a7a28506 ^

6ef1174b ^
a7a28506 ^
5f25d993 ^
3d7d070b ^
a2726b6a ^

f7843def ^
36790dc2 ^
f7843def ^


a2726b6a ^

f7843def ^

36790dc2 ^
f7843def ^

2cdbfc7e ^
a2726b6a ^
2cdbfc7e ^



a2726b6a ^
2cdbfc7e ^
a2726b6a ^
2cdbfc7e ^








3d7d070b ^








a2726b6a ^
3d7d070b ^
a2726b6a ^

3d7d070b ^
a2726b6a ^
3d7d070b ^
a2726b6a ^
3d7d070b ^





a2726b6a ^

3d7d070b ^







a2726b6a ^
3d7d070b ^








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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141


                   
                   


                   
                   

                   
                    
                               
                              
 

                               

                                                                  
                                                                      

                           

 

                               




                                                     

                             

                                                              
                                                                    

                           
 
 

                             




                                                   

                              

                             
                                                                             
            
                         
     
              

 

                               
 

                                                             
                             
                           
 
 

                                
 
                           


                         

                                 

                          
                            

 
   
                                        



                
                                    
              
                                                     








                                           








                                
                                                              
 

                                 
 
                  
                           
                





                                           

                                           







                                                 
                        








                                                                      
#include <setjmp.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
#include <cmocka.h>
#include <glib.h>
#include <stdio.h>
#include <unistd.h>

#include "common.h"
#include "helpers.h"
#include "config/preferences.h"
#include "xmpp/chat_session.h"

void
create_config_dir(void** state)
{
    setenv("XDG_CONFIG_HOME", "./tests/files/xdg_config_home", 1);
    if (!mkdir_recursive("./tests/files/xdg_config_home/profanity")) {
        assert_true(FALSE);
    }
}

void
remove_config_dir(void** state)
{
    rmdir("./tests/files/xdg_config_home/profanity");
    rmdir("./tests/files/xdg_config_home");
}

void
create_data_dir(void** state)
{
    setenv("XDG_DATA_HOME", "./tests/files/xdg_data_home", 1);
    if (!mkdir_recursive("./tests/files/xdg_data_home/profanity")) {
        assert_true(FALSE);
    }
}

void
remove_data_dir(void** state)
{
    rmdir("./tests/files/xdg_data_home/profanity");
    rmdir("./tests/files/xdg_data_home");
}

void
load_preferences(void** state)
{
    create_config_dir(state);
    FILE* f = fopen("./tests/files/xdg_config_home/profanity/profrc", "ab+");
    if (f) {
        prefs_load(NULL);
    }
    fclose(f);
}

void
close_preferences(void** state)
{
    prefs_close();
    remove("./tests/files/xdg_config_home/profanity/profrc");
    remove_config_dir(state);
    rmdir("./tests/files");
}

void
init_chat_sessions(void** state)
{
    load_preferences(NULL);
    chat_sessions_init();
}

void
close_chat_sessions(void** state)
{
    chat_sessions_clear();
    close_preferences(NULL);
}

int
utf8_pos_to_col(char* str, int utf8_pos)
{
    int col = 0;

    int i = 0;
    for (i = 0; i < utf8_pos; i++) {
        col++;
        gchar* ch = g_utf8_offset_to_pointer(str, i);
        gunichar uni = g_utf8_get_char(ch);
        if (g_unichar_iswide(uni)) {
            col++;
        }
    }

    return col;
}

static GCompareFunc cmp_func;

void
glist_set_cmp(GCompareFunc func)
{
    cmp_func = func;
}

int
glist_contents_equal(const void* actual, const void* expected)
{
    GList* ac = (GList*)actual;
    GList* ex = (GList*)expected;

    GList* p = ex;
    printf("\nExpected\n");
    while (ex) {
        printf("\n\n%s\n", (char*)p->data);
        ex = g_list_next(ex);
    }
    printf("\n\n");
    p = ac;
    printf("\nActual\n");
    while (ac) {
        printf("\n\n%s\n", (char*)p->data);
        ac = g_list_next(ac);
    }
    printf("\n\n");

    if (g_list_length(ex) != g_list_length(ac)) {
        return 0;
    }

    GList* ex_curr = ex;
    while (ex_curr != NULL) {
        if (g_list_find_custom(ac, ex_curr->data, cmp_func) == NULL) {
            return 0;
        }
        ex_curr = g_list_next(ex_curr);
    }

    return 1;
}