I am currently trying to test a function with an infinite loop and im having a problem how to break.
Is there anyway I can test this?
Thanks in advance.

void classA::process()
    unsigned int return_val;
    proxy_class& proxy = proxy.instance();

    while(1) {
        return_val = proxy.run();
        if(0 == return_val) {
            //some code here


Recommended Answers

Try replacing // some code here with break;

Jump to Post

All 3 Replies

Try replacing // some code here with break;

i forgot to mention that i should not change the codes above. i just have to test the function.

Well, as the code currently stands, while (1), it will run infinitely. The only way to break out of it is with a break; statement if a particular condition is true. That is, if you want to keep the while (1) part.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.