about summary refs log tree commit diff stats
path: root/html/001help.cc.html
blob: d1a53d634a32cc933a006fb98592187472800f98 (plain) (blame)
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>~/Desktop/s/mu/001help.cc</title>
<meta name="Generator" content="Vim/7.4">
<meta name="plugin-version" content="vim7.4_v1">
<meta name="syntax" content="cpp">
<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">
<meta name="colorscheme" content="minimal">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; }
body { font-family: monospace; color: #d0d0d0; background-color: #000000; }
* { font-size: 1em; }
.cSpecial { color: #008000; }
.Constant { color: #008080; }
.Comment { color: #8080ff; }
.Delimiter { color: #c000c0; }
.SalientComment { color: #00ffff; }
.Identifier { color: #008080; }
.PreProc { color: #c000c0; }
-->
</style>

<script type='text/javascript'>
<!--

-->
</script>
</head>
<body>
<pre id='vimCodeElement'>
<span class="Comment">//: Everything this project/binary supports.</span>
<span class="Comment">//: This should give you a sense for what to look forward to in later layers.</span>

<span class="Delimiter">:(before &quot;End Commandline Parsing&quot;)</span>
if <span class="Delimiter">(</span>argc &lt;= <span class="Constant">1</span> || is_equal<span class="Delimiter">(</span>argv[<span class="Constant">1</span>]<span class="Delimiter">,</span> <span class="Constant">&quot;--help&quot;</span><span class="Delimiter">))</span> <span class="Delimiter">{</span>
  <span class="Comment">// this is the functionality later layers will provide</span>
  <span class="Comment">// currently no automated tests for commandline arg parsing</span>
  cerr &lt;&lt; <span class="Constant">&quot;To load files and run 'main':</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span>
       &lt;&lt; <span class="Constant">&quot;  mu file1.mu file2.mu ...</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span>
       &lt;&lt; <span class="Constant">&quot;To run all tests:</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span>
       &lt;&lt; <span class="Constant">&quot;  mu test</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span>
       &lt;&lt; <span class="Constant">&quot;To load files and then run all tests:</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span>
       &lt;&lt; <span class="Constant">&quot;  mu test file1.mu file2.mu ...</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span>
       <span class="Delimiter">;</span>
  <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="SalientComment">//:: Helper function used by the above fragment of code (and later layers too,</span>
<span class="SalientComment">//:: who knows?).</span>
<span class="Comment">//: The :(code) directive appends function definitions to the end of the</span>
<span class="Comment">//: project. Regardless of where functions are defined, we can call them</span>
<span class="Comment">//: anywhere we like as long as we format the function header in a specific</span>
<span class="Comment">//: way: put it all on a single line without indent, end the line with ') {'</span>
<span class="Comment">//: and no trailing whitespace. As long as functions uniformly start this</span>
<span class="Comment">//: way, our makefile contains a little command to automatically generate</span>
<span class="Comment">//: declarations for them.</span>
<span class="Delimiter">:(code)</span>
bool is_equal<span class="Delimiter">(</span>char* s<span class="Delimiter">,</span> const char* lit<span class="Delimiter">)</span> <span class="Delimiter">{</span>
  <span class="Identifier">return</span> strncmp<span class="Delimiter">(</span>s<span class="Delimiter">,</span> lit<span class="Delimiter">,</span> strlen<span class="Delimiter">(</span>lit<span class="Delimiter">))</span> == <span class="Constant">0</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Includes&quot;)</span>
<span class="PreProc">#include</span><span class="Constant">&lt;assert.h&gt;</span>

<span class="PreProc">#include</span><span class="Constant">&lt;iostream&gt;</span>
using std::istream<span class="Delimiter">;</span>
using std::ostream<span class="Delimiter">;</span>
using std::iostream<span class="Delimiter">;</span>
using std::cin<span class="Delimiter">;</span>
using std::cout<span class="Delimiter">;</span>
using std::cerr<span class="Delimiter">;</span>

<span class="PreProc">#include</span><span class="Constant">&lt;cstring&gt;</span>
<span class="PreProc">#include</span><span class="Constant">&lt;string&gt;</span>
using std::string<span class="Delimiter">;</span>
typedef size_t index_t<span class="Delimiter">;</span>
const index_t NOT_FOUND = string::npos<span class="Delimiter">;</span>
<span class="Delimiter">:(after &quot;int main(int argc, char* argv[])&quot;)</span>
assert<span class="Delimiter">(</span>sizeof<span class="Delimiter">(</span>string::size_type<span class="Delimiter">)</span> == sizeof<span class="Delimiter">(</span>size_t<span class="Delimiter">));</span>
assert<span class="Delimiter">(</span>sizeof<span class="Delimiter">(</span>index_t<span class="Delimiter">)</span> == sizeof<span class="Delimiter">(</span>size_t<span class="Delimiter">));</span>
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->
">gchar *args[] = { "muc", "all", NULL }; expect_cons_show("All presence updates will appear in chat room windows."); gboolean result = cmd_statuses(NULL, args, *help); char *setting = prefs_get_string(PREF_STATUSES_MUC); assert_non_null(setting); assert_string_equal("all", setting); assert_true(result); free(help); } void cmd_statuses_muc_sets_online(void **state) { CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "muc", "online", NULL }; expect_cons_show("Only join/leave presence updates will appear in chat room windows."); gboolean result = cmd_statuses(NULL, args, *help); char *setting = prefs_get_string(PREF_STATUSES_MUC); assert_non_null(setting); assert_string_equal("online", setting); assert_true(result); free(help); } void cmd_statuses_muc_sets_none(void **state) { CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "muc", "none", NULL }; expect_cons_show("Presence updates will not appear in chat room windows."); gboolean result = cmd_statuses(NULL, args, *help); char *setting = prefs_get_string(PREF_STATUSES_MUC); assert_non_null(setting); assert_string_equal("none", setting); assert_true(result); free(help); }