Merge lp:~thomas-voss/compiz-core/fix-option-color into lp:compiz-core/0.9.5

Proposed by Sam Spilsbury
Status: Rejected
Rejected by: Sam Spilsbury
Proposed branch: lp:~thomas-voss/compiz-core/fix-option-color
Merge into: lp:compiz-core/0.9.5
Diff against target: 79 lines (+36/-1)
2 files modified
include/core/option.h (+13/-0)
src/option/tests/option.cpp (+23/-1)
To merge this branch: bzr merge lp:~thomas-voss/compiz-core/fix-option-color
Reviewer Review Type Date Requested Status
Compiz Maintainers Pending
Review via email: mp+90107@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

"void set( unsigned short s[4] )" - is that really intended? As opposed to, say, "void set( unsigned short (& s)[4] )" or "void set( unsigned short* s )"?

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/core/option.h'
2--- include/core/option.h 2012-01-24 15:22:49 +0000
3+++ include/core/option.h 2012-01-25 13:34:23 +0000
4@@ -97,6 +97,11 @@
5 mValue(t)
6 {
7 }
8+
9+ Value( unsigned short c[4] ) : mListType(TypeUnset),
10+ mValue( static_cast<unsigned short*>(c) )
11+ {
12+ }
13
14 ~Value();
15
16@@ -117,6 +122,14 @@
17 {
18 mValue = t;
19 }
20+
21+ void set( const char* c ) {
22+ mValue = CompString(c);
23+ }
24+
25+ void set( unsigned short s[4] ) {
26+ mValue = static_cast<unsigned short*>(s);
27+ }
28
29 /* In order to be exception safe, this MUST
30 * return a copy. Prefer to use a specific
31
32=== modified file 'src/option/tests/option.cpp'
33--- src/option/tests/option.cpp 2012-01-18 16:56:31 +0000
34+++ src/option/tests/option.cpp 2012-01-25 13:34:23 +0000
35@@ -15,6 +15,9 @@
36 ASSERT_EQ(v.type(),type);
37 ASSERT_EQ (v.get<T>(),value);
38 }
39+
40+ unsigned short testColor[4] = {255, 0, 255, 0};
41+ unsigned short testColor2[4] = {0, 255, 0, 255};
42 }
43
44 TEST(CompOption,Value)
45@@ -26,10 +29,13 @@
46 check_type_value<int> (CompOption::TypeInt, 1);
47 check_type_value<float> (CompOption::TypeFloat, 1.f);
48 check_type_value<CompString> (CompOption::TypeString, CompString("Check"));
49-
50+ check_type_value<CompString> (CompOption::TypeString,"core");
51+
52 check_type_value<CompAction> (CompOption::TypeAction, CompAction());
53 check_type_value<CompMatch> (CompOption::TypeMatch, CompMatch());
54
55+ check_type_value<unsigned short*> (CompOption::TypeColor, testColor);
56+
57 check_type_value<CompOption::Value::Vector> (CompOption::TypeList, CompOption::Value::Vector(5));
58
59 CompOption::Value v1, v2;
60@@ -37,3 +43,19 @@
61 v1.set (CompString("SomeString"));
62 ASSERT_TRUE(v1 != v2);
63 }
64+
65+TEST(CompOption,Color)
66+{
67+
68+ CompOption::Value value(testColor);
69+ unsigned short * color = value.c();
70+ std::cout << "color: " << color[0] << color[1] << color[2] << color[3] << std::endl;
71+ color = value.get<unsigned short*>();
72+ std::cout << "color: " << color[0] << color[1] << color[2] << color[3] << std::endl;
73+ value.set(testColor2);
74+ color = value.c();
75+ std::cout << "color: " << color[0] << color[1] << color[2] << color[3] << std::endl;
76+ color = value.get<unsigned short*>();
77+ std::cout << "color: " << color[0] << color[1] << color[2] << color[3] << std::endl;
78+
79+}

Subscribers

People subscribed via source and target branches