Adding XCTest unit tests to existing app doesn't work
I've added tests (XCTests) to an existing C++ command line app in Xcode 5
via Test Navigator > (+),
changed the extension of the test class to .mm,
added the XCTest framework to the project.
All compiles fine. Now running the tests just gives me a 'Test failed'
message, nothing in the console and neither green nor red lights in the
Navigator (i.e. no tests executed).
Starting with a fresh Xcode 5 project and changing the extension of the
test class to .mm just works fine so I'd assume it's not just about
lacking support for Objective-C++ in XCTest.
Even with a plain, vanilla test target added to the existing C++ project
the tests fail before ever running.
Any more gotchas to watch out for when adding XCTests to existing
(Objective-)C++ targets?
Thursday, 3 October 2013
Wednesday, 2 October 2013
C, error: control reaches end of non-void function [-Werror,-Wreturn-type]
C, error: control reaches end of non-void function [-Werror,-Wreturn-type]
struct quad {
int a;
int b;
int c;
}
int f(const int a, const int b, const int c, const int x){
const int l = a*x*x + b*x + c;
return l;
}
int safe_quad_eval(const struct quad q, const int x){
(f(q.a,q.b,q.c,x)>INT_MAX)||(f(q.a,q.b,q.c,x)<(-INT_MAX)) ? INT_MIN :
f(q.a,q.b,q.c,x);
}
I'm not sure what does this error mean? and how to solve it?
struct quad {
int a;
int b;
int c;
}
int f(const int a, const int b, const int c, const int x){
const int l = a*x*x + b*x + c;
return l;
}
int safe_quad_eval(const struct quad q, const int x){
(f(q.a,q.b,q.c,x)>INT_MAX)||(f(q.a,q.b,q.c,x)<(-INT_MAX)) ? INT_MIN :
f(q.a,q.b,q.c,x);
}
I'm not sure what does this error mean? and how to solve it?
Need help cleaning up fibonacci sequence using C++ please
Need help cleaning up fibonacci sequence using C++ please
I'm still very new to C++ still and decided to make a fibonacci sequence.
It worked (Woo!) but it doesn't work as well as I would like it to.
what I mean by that is say for example I told my program to count the
first 10 terms of the sequence I will get
"0, 1, 1" and then I have to press enter for each additional number until
it hits ten in which case the program returns 0 and ends.
How do I get the program to display all the numbers I want to without
hitting enter for each additional one?
Here is my script:
#include <iostream>
using namespace std;
int main()
{
int FibNum;
cout << "How many numbers of the Fibonacci Sequence would you like to
see? \n\n";
cin>> FibNum;
cin.ignore();
int a = 0;
int b = 1;
int c = 2;
cout << "Fibonacci Sequence up to " << FibNum << " terms.\n\n";
cout << a << "\n" << b << "\n";
for (int c = 2; c < FibNum; c++) {
int d = a + b;
cout << d;
cin.ignore();
a = b;
b = d;
}
}
Thanks in advance for any help!
P.s. Also if you notice anything terrible I'm doing please feel free to
correct me, I'm very aware I'm probably doing a lot wrong, I'm just trying
to learn. :]
I'm still very new to C++ still and decided to make a fibonacci sequence.
It worked (Woo!) but it doesn't work as well as I would like it to.
what I mean by that is say for example I told my program to count the
first 10 terms of the sequence I will get
"0, 1, 1" and then I have to press enter for each additional number until
it hits ten in which case the program returns 0 and ends.
How do I get the program to display all the numbers I want to without
hitting enter for each additional one?
Here is my script:
#include <iostream>
using namespace std;
int main()
{
int FibNum;
cout << "How many numbers of the Fibonacci Sequence would you like to
see? \n\n";
cin>> FibNum;
cin.ignore();
int a = 0;
int b = 1;
int c = 2;
cout << "Fibonacci Sequence up to " << FibNum << " terms.\n\n";
cout << a << "\n" << b << "\n";
for (int c = 2; c < FibNum; c++) {
int d = a + b;
cout << d;
cin.ignore();
a = b;
b = d;
}
}
Thanks in advance for any help!
P.s. Also if you notice anything terrible I'm doing please feel free to
correct me, I'm very aware I'm probably doing a lot wrong, I'm just trying
to learn. :]
Linq To Entities 5 re-use Expression in another entity
Linq To Entities 5 re-use Expression in another entity
I've been trying to find this, but I've not had luck. Say I have a
database with 2 tables, person and address.
table person
id int
name varchar(50)
addressId int
table address
id int
street varchar(50)
country varchar(50)
In my data layer, I have a business object for Address, which is exposed
to external callers. I found an expression that I could use to centralize
my creation code at the SQL level. This way I don't have to write:
db.Address.Select( x => new Biz.Address{ street = x.street} ).ToList();
//and all the other properties etc
everywhere. Instead I can now do:
db.Address.Select(AddressDto.ToDto).ToList();
Using this code:
internal static class AddressDto
{
internal static readonly Expression<Func<Address, Biz.Address>> ToDto =
src => new Biz.Address
{
Id = src.id,
Street = src.street,
Country = src.country
};
}
The problem is now that I am trying to do the same thing for the Person
object, and I want to re-use this method to fill in the address. However I
can't seem to utilize an expression in it.
class Person
{
int Id;
string Name;
Address address;
}
internal static class PersonDto
{
internal static readonly Expression<Func<Person, Biz.Person>> ToDto =
src => new Biz.Person
{
Id = src.id,
Name = src.name,
address = src.Address //How do i set this to an
expression?
};
}
The reason I ask for the expression, is because while it compiles fine if
I use a normal method, it blows up at runtime, because it can't translate
that to the object store. However, if I do:
address = AddressDto.ToDto(src.Address)
the compiler rejects that, as it wants a method, delegate, or event. I'd
love to find a way to do this. the idea I'm trying to implement is to
basically centralize the code that maps the Entity to the business object,
so that my other code is kept clean and maintenance is easier when the
schema changes. If there is a different method signature I have to create
and maintain, that'd be fine, as I'd place it in the same file and live
with it. I just can't seem to find the magic combination that'll make this
work.
Thanks!
I've been trying to find this, but I've not had luck. Say I have a
database with 2 tables, person and address.
table person
id int
name varchar(50)
addressId int
table address
id int
street varchar(50)
country varchar(50)
In my data layer, I have a business object for Address, which is exposed
to external callers. I found an expression that I could use to centralize
my creation code at the SQL level. This way I don't have to write:
db.Address.Select( x => new Biz.Address{ street = x.street} ).ToList();
//and all the other properties etc
everywhere. Instead I can now do:
db.Address.Select(AddressDto.ToDto).ToList();
Using this code:
internal static class AddressDto
{
internal static readonly Expression<Func<Address, Biz.Address>> ToDto =
src => new Biz.Address
{
Id = src.id,
Street = src.street,
Country = src.country
};
}
The problem is now that I am trying to do the same thing for the Person
object, and I want to re-use this method to fill in the address. However I
can't seem to utilize an expression in it.
class Person
{
int Id;
string Name;
Address address;
}
internal static class PersonDto
{
internal static readonly Expression<Func<Person, Biz.Person>> ToDto =
src => new Biz.Person
{
Id = src.id,
Name = src.name,
address = src.Address //How do i set this to an
expression?
};
}
The reason I ask for the expression, is because while it compiles fine if
I use a normal method, it blows up at runtime, because it can't translate
that to the object store. However, if I do:
address = AddressDto.ToDto(src.Address)
the compiler rejects that, as it wants a method, delegate, or event. I'd
love to find a way to do this. the idea I'm trying to implement is to
basically centralize the code that maps the Entity to the business object,
so that my other code is kept clean and maintenance is easier when the
schema changes. If there is a different method signature I have to create
and maintain, that'd be fine, as I'd place it in the same file and live
with it. I just can't seem to find the magic combination that'll make this
work.
Thanks!
Add "Black right-pointing pointer" HTML entitiy in css content
Add "Black right-pointing pointer" HTML entitiy in css content
I'm trying to add a "Black right-pointing pointer" html entity into my css
:after content but to no avail.
I know you need to use a unicode value but I can't find one that works for
this. This is the unicode number U+25BA and this is the HTML code ►
I'm trying to add a "Black right-pointing pointer" html entity into my css
:after content but to no avail.
I know you need to use a unicode value but I can't find one that works for
this. This is the unicode number U+25BA and this is the HTML code ►
Tuesday, 1 October 2013
Dynamically change only one element in tooltip title using tooltipster
Dynamically change only one element in tooltip title using tooltipster
I have a set of options in a tooltipster title element, like follow:
<i class="icon-cog settings" title="
<div class='div1' onclick='follow(1,2)'>Content 1</div>
<div class='div2' ...>Content 2</div>
<div class='div3' ...>Content 3</div>
">
</i>
When the div1 is clicked, the content is dinamically updated by a ajax
result based on the following function:
function follow(f1,f2) {
$.get('/exe/add_followers.php?f1=' + f1 + '&f2=' + f2, function (result) {
$('.div'+f2).html('content 1 is updated to' + result.newcontent);
}, 'json');
}
The problem is that when the tooltip is closed and the page has not been
refreshed, the content returns to the initial value instead of showing the
updated value.
I tried to use a configuration option as described Here:
function follow(f1,f2) {
$.get('/exe/add_followers.php?f1=' + f1 + '&f2=' + f2, function
(result) {
// $('.div'+f2).html('content 1 is updated to' + result.newcontent);
$('.setting').tooltipster('update', 'content 1 is updated to' +
result.newcontent);
}, 'json');
}
However, this change the div1's content but removes the content of other
divs. How can I update only the content of div1 and leave the other
unchanged?
I have a set of options in a tooltipster title element, like follow:
<i class="icon-cog settings" title="
<div class='div1' onclick='follow(1,2)'>Content 1</div>
<div class='div2' ...>Content 2</div>
<div class='div3' ...>Content 3</div>
">
</i>
When the div1 is clicked, the content is dinamically updated by a ajax
result based on the following function:
function follow(f1,f2) {
$.get('/exe/add_followers.php?f1=' + f1 + '&f2=' + f2, function (result) {
$('.div'+f2).html('content 1 is updated to' + result.newcontent);
}, 'json');
}
The problem is that when the tooltip is closed and the page has not been
refreshed, the content returns to the initial value instead of showing the
updated value.
I tried to use a configuration option as described Here:
function follow(f1,f2) {
$.get('/exe/add_followers.php?f1=' + f1 + '&f2=' + f2, function
(result) {
// $('.div'+f2).html('content 1 is updated to' + result.newcontent);
$('.setting').tooltipster('update', 'content 1 is updated to' +
result.newcontent);
}, 'json');
}
However, this change the div1's content but removes the content of other
divs. How can I update only the content of div1 and leave the other
unchanged?
How to write into Cassandra with Byte Array following Big Endian Byte Order?
How to write into Cassandra with Byte Array following Big Endian Byte Order?
I need to write Byte Array value into Cassandra using Java code. Then I
will be having my C++ program which will retrieve that Byte Array data
from Cassandra and then it will deserialize it.
That Byte Array which I will be writing into Cassandra is made up of three
Byte Arrays as described below-
short schemaId = 32767;
long lastModifiedDate = "1379811105109L";
byte[] avroBinaryValue = os.toByteArray();
Now, I will write schemaId , lastModifiedDate and avroBinaryValue together
into a single Byte Array and that resulting Byte Array I will write into
Cassandra and then I will be having my C++ program which will retrieve
that Byte Array data from Cassandra and then deserialize it to extract
schemaId , lastModifiedDate and avroBinaryValue from it.
I am not sure whether I should use Big Endian here in my Java code while
writing to Cassandra so that C++ code get simplified while reading it
back? I have given a try on the Java side to make sure it is following
certain format (Big Endian) while writing into Byte Array but not sure
whether this is right or not?
public static void main(String[] args) throws Exception {
String os = "Byte Array Test";
byte[] avroBinaryValue = os.getBytes();
long lastModifiedDate = 1379811105109L;
short schemaId = 32767;
ByteArrayOutputStream byteOsTest = new ByteArrayOutputStream();
DataOutputStream outTest = new DataOutputStream(byteOsTest);
outTest.writeShort(schemaId);
outTest.writeLong(lastModifiedDate);
outTest.writeInt(avroBinaryValue.length);
outTest.write(avroBinaryValue);
byte[] allWrittenBytesTest = byteOsTest.toByteArray();
ByteBuffer bb =
ByteBuffer.wrap(allWrittenBytesTest).order(ByteOrder.BIG_ENDIAN);
// now what value I should write into Cassandra?
// or does this even looks right?
// And now how to deserialize it?
}
Can anyone help me with this ByteBuffer thing here? Thanks..
I need to write Byte Array value into Cassandra using Java code. Then I
will be having my C++ program which will retrieve that Byte Array data
from Cassandra and then it will deserialize it.
That Byte Array which I will be writing into Cassandra is made up of three
Byte Arrays as described below-
short schemaId = 32767;
long lastModifiedDate = "1379811105109L";
byte[] avroBinaryValue = os.toByteArray();
Now, I will write schemaId , lastModifiedDate and avroBinaryValue together
into a single Byte Array and that resulting Byte Array I will write into
Cassandra and then I will be having my C++ program which will retrieve
that Byte Array data from Cassandra and then deserialize it to extract
schemaId , lastModifiedDate and avroBinaryValue from it.
I am not sure whether I should use Big Endian here in my Java code while
writing to Cassandra so that C++ code get simplified while reading it
back? I have given a try on the Java side to make sure it is following
certain format (Big Endian) while writing into Byte Array but not sure
whether this is right or not?
public static void main(String[] args) throws Exception {
String os = "Byte Array Test";
byte[] avroBinaryValue = os.getBytes();
long lastModifiedDate = 1379811105109L;
short schemaId = 32767;
ByteArrayOutputStream byteOsTest = new ByteArrayOutputStream();
DataOutputStream outTest = new DataOutputStream(byteOsTest);
outTest.writeShort(schemaId);
outTest.writeLong(lastModifiedDate);
outTest.writeInt(avroBinaryValue.length);
outTest.write(avroBinaryValue);
byte[] allWrittenBytesTest = byteOsTest.toByteArray();
ByteBuffer bb =
ByteBuffer.wrap(allWrittenBytesTest).order(ByteOrder.BIG_ENDIAN);
// now what value I should write into Cassandra?
// or does this even looks right?
// And now how to deserialize it?
}
Can anyone help me with this ByteBuffer thing here? Thanks..
Ubuntu Button is too slow
Ubuntu Button is too slow
When I push Ubuntu Button, it sometimes takes the menu up to 10 seconds to
appear. Or at least 4 seconds in average.
How do I make it faster?
When I push Ubuntu Button, it sometimes takes the menu up to 10 seconds to
appear. Or at least 4 seconds in average.
How do I make it faster?
Describe explicitly the $M$-measurable functions in case $M$ is one of the following $\sigma$-algebras:
Describe explicitly the $M$-measurable functions in case $M$ is one of the
following $\sigma$-algebras:
Describe explicitly the $M$-measurable functions in case $M$ is one of the
following $\sigma$-algebras:
(a) $M=\{\emptyset,X\}$
(b) $M=2^{X}$
(c) For certain disjoint sets $E_1,...,E_N$, $X=\cup_{k=1}^N E_k$, and $M$
is the algebra (in fact, $\sigma$-algebra) generated by the collection of
sets $\{E_1,...,E_N\}$.
Here's my book's definition of $M$-measurable:
Suppose $f:X\to[-\infty,\infty]$. Then $f$ is $M$-measurable if for all
$t\in[-\infty,\infty]$ the set $f^{-1}([-\infty,t])$ belongs to $M$. Inn
other words, $\{x\in X|f(x)\le t\}\in M$.
Of course, the form of the inequality $f(x)\le t$ is arbitrary.
Thanks.
following $\sigma$-algebras:
Describe explicitly the $M$-measurable functions in case $M$ is one of the
following $\sigma$-algebras:
(a) $M=\{\emptyset,X\}$
(b) $M=2^{X}$
(c) For certain disjoint sets $E_1,...,E_N$, $X=\cup_{k=1}^N E_k$, and $M$
is the algebra (in fact, $\sigma$-algebra) generated by the collection of
sets $\{E_1,...,E_N\}$.
Here's my book's definition of $M$-measurable:
Suppose $f:X\to[-\infty,\infty]$. Then $f$ is $M$-measurable if for all
$t\in[-\infty,\infty]$ the set $f^{-1}([-\infty,t])$ belongs to $M$. Inn
other words, $\{x\in X|f(x)\le t\}\in M$.
Of course, the form of the inequality $f(x)\le t$ is arbitrary.
Thanks.
Subscribe to:
Posts (Atom)