Skip to content

Commit

Permalink
Test for C++ reference initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
nfeske committed Apr 22, 2015
1 parent 2e672b3 commit 1d78f58
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
55 changes: 55 additions & 0 deletions repos/base/src/test/cxx/main.cc
@@ -0,0 +1,55 @@
/*
* \brief Test case for C++11-style reference initializer
* \author Norman Feske
* \date 2015-04-22
*/

/*
* Copyright (C) 2015 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/

/* Genode includes */
#include <base/printf.h>
#include <base/env.h>


struct Wrapped_value
{
int const value;
Wrapped_value() : value(1) { }
};


struct Object_with_ref
{
Wrapped_value const &_value;
Object_with_ref(Wrapped_value const &value);
};


Object_with_ref::Object_with_ref(Wrapped_value const &value)
:
_value{value}
{ }


int main() {

Wrapped_value value;

Genode::printf("value: %d (expect 1)\n", value.value);

Object_with_ref object_with_ref(value);

int const v = object_with_ref._value.value;
if (v != 1) {
PERR("unexpected value %d (0x%x)", v, v);
return 1;
}

PDBG("test completed successfully");
return 0;
}
3 changes: 3 additions & 0 deletions repos/base/src/test/cxx/target.mk
@@ -0,0 +1,3 @@
TARGET = test-cxx
SRC_CC = main.cc
LIBS = base cxx

0 comments on commit 1d78f58

Please sign in to comment.