about summary refs log tree commit diff stats
path: root/src/config/conflists.c
Commit message (Collapse)AuthorAgeFilesLines
* Add config.h in files were it was missingMichael Vetter2021-03-261-0/+2
| | | | Related to https://github.com/profanity-im/profanity/issues/1512
* Apply coding styleMichael Vetter2020-07-071-11/+11
|
* Revert "Apply coding style"Michael Vetter2020-07-071-12/+12
| | | | | | This reverts commit 9b55f2dec0ea27a9ce4856e303425e12f866cea2. Sorting the includes creates some problems.
* Apply coding styleMichael Vetter2020-07-071-12/+12
| | | | Regards https://github.com/profanity-im/profanity/issues/1396
* Add vim modelineMichael Vetter2019-11-131-0/+1
|
* Update copyright to include 2019Michael Vetter2019-01-221-1/+1
|
* Update copyrightJames Booth2018-01-211-1/+1
|
* Update CopyrightJames Booth2017-01-281-1/+1
|
* Update GPL link in headersJames Booth2016-07-241-1/+1
|
* Remove string allocation for conflistsJames Booth2016-07-101-3/+3
|
* Updated copyrightJames Booth2016-02-141-1/+1
|
* Added conf_string_list_addJames Booth2015-11-241-0/+49
|
* Created config/conflists.c for shared config list handlingJames Booth2015-11-231-0/+82
ht: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
void test_trace_check_compares() {
  CHECK_TRACE_CONTENTS("test layer", "");
  trace("test layer") << "foo";
  CHECK_TRACE_CONTENTS("test layer", "foo");
}

void test_trace_check_filters_layers() {
  trace("test layer 1") << "foo";
  trace("test layer 2") << "bar";
  CHECK_TRACE_CONTENTS("test layer 1", "foo");
}

void test_trace_check_ignores_other_lines() {
  trace("test layer 1") << "foo";
  trace("test layer 1") << "bar";
  CHECK_TRACE_CONTENTS("test layer 1", "foo");
}

void test_trace_check_always_finds_empty_lines() {
  CHECK_TRACE_CONTENTS("test layer 1", "");
}

void test_trace_check_treats_empty_layers_as_wildcards() {
  trace("test layer 1") << "foo";
  CHECK_TRACE_CONTENTS("", "foo");
}

void test_trace_check_multiple_lines_at_once() {
  trace("test layer 1") << "foo";
  trace("test layer 2") << "bar";
  CHECK_TRACE_CONTENTS("", "foobar");
}

void test_trace_check_always_finds_empty_lines2() {
  CHECK_TRACE_CONTENTS("test layer 1", "");
}

void test_trace_orders_across_layers() {
  trace("test layer 1") << "foo";
  trace("test layer 2") << "bar";
  trace("test layer 1") << "qux";
  CHECK_TRACE_CONTENTS("", "foobarqux");
}

void test_trace_orders_across_layers2() {
  trace("test layer 1") << "foo";
  trace("test layer 2") << "bar";
  trace("test layer 1") << "qux";
  CHECK_TRACE_CONTENTS("foobarqux");
}

void test_trace_checks_ordering_spanning_multiple_layers() {
  trace("layer1") << "foo";
  trace("layer2") << "bar";
  trace("layer1") << "qux";
  CHECK_TRACE_CONTENTS("layer1: foolayer2: barlayer1: qux");
}

void test_trace_segments_within_layers() {
  trace("test layer 1") << "foo";
  trace("test layer 2") << "bar";
  new_trace_frame("test layer 1");
  trace("test layer 1") << "qux";
  CHECK_TRACE_CONTENTS("test layer 1", "fooqux");
  CHECK_TRACE_CONTENTS("test layer 1", 0, "foo");
  CHECK_TRACE_DOESNT_CONTAIN("test layer 1", 1, "foo");
}

void test_trace_checks_ordering_across_layers_and_frames() {
  trace("test layer 1") << "foo";
  trace("test layer 2") << "bar";
  new_trace_frame("test layer 1");
  trace("test layer 1") << "qux";
  CHECK_TRACE_CONTENTS("test layer 1/0: footest layer 2: bartest layer 1: qux");
  CHECK_TRACE_CONTENTS("test layer 1: footest layer 2: bartest layer 1/1: qux");
}

void trace_test_fn(int n) {
  if (n == 0) return;
  new_trace_frame("foo");
  trace("foo") << "before: " << n;
  trace_test_fn(n-1);
  trace("foo") << "after: " << n;
}

void test_trace_keeps_level_together() {
  CHECK_TRACE_CONTENTS("foo", "");
  trace_test_fn(4);
  CHECK_TRACE_CONTENTS("foo", 2, "before: 3after: 3");
}

void test_trace_supports_multiple_layers() {
  trace("test layer 1") << "foo";
  trace("test layer 2") << "bar";
  trace("test layer 1") << "qux";
  CHECK_TRACE_CONTENTS("test layer 1,test layer 2", "foobarqux");
}

void test_trace_supports_hierarchical_layers() {
  trace("test layer/a") << "foo";
  trace("different layer/c") << "foo 2";
  trace("test layer/b") << "bar";
  CHECK_TRACE_CONTENTS("test layer/", "foobar");
}

void test_trace_supports_count() {
  trace("test layer 1") << "foo";
  trace("test layer 1") << "foo";
  CHECK_EQ(trace_count("test layer 1", "foo"), 2);
}

void test_trace_supports_count2() {
  trace("test layer 1") << "foo";
  trace("test layer 1") << "bar";
  CHECK_EQ(trace_count("test layer 1"), 2);
}

// pending: DUMP tests
// pending: readable_contents() adds newline if necessary.
// pending: RAISE also prints to stderr.
// pending: RAISE doesn't print to stderr if Hide_warnings is set.
// pending: RAISE doesn't have to be saved if Hide_warnings is set, just printed.
// pending: RAISE prints to stderr if Trace_stream is NULL.
// pending: RAISE prints to stderr if Trace_stream is NULL even if Hide_warnings is set.
// pending: RAISE << ... die() doesn't die if Hide_warnings is set.



// can't check trace because trace methods call 'split'

void test_split_returns_at_least_one_elem() {
  vector<string> result = split("", ",");
  CHECK_EQ(result.size(), 1);
  CHECK_EQ(result[0], "");
}

void test_split_returns_entire_input_when_no_delim() {
  vector<string> result = split("abc", ",");
  CHECK_EQ(result.size(), 1);
  CHECK_EQ(result[0], "abc");
}

void test_split_works() {
  vector<string> result = split("abc,def", ",");
  CHECK_EQ(result.size(), 2);
  CHECK_EQ(result[0], "abc");
  CHECK_EQ(result[1], "def");
}

void test_split_works2() {
  vector<string> result = split("abc,def,ghi", ",");
  CHECK_EQ(result.size(), 3);
  CHECK_EQ(result[0], "abc");
  CHECK_EQ(result[1], "def");
  CHECK_EQ(result[2], "ghi");
}

void test_split_handles_multichar_delim() {
  vector<string> result = split("abc,,def,,ghi", ",,");
  CHECK_EQ(result.size(), 3);
  CHECK_EQ(result[0], "abc");
  CHECK_EQ(result[1], "def");
  CHECK_EQ(result[2], "ghi");
}