BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
progresshandler.test.cpp File Reference

Implements class CLASS? More...

Include dependency graph for progresshandler.test.cpp:

Go to the source code of this file.

Classes

class  ProgressHandlerTest
 

Functions

 TEST_F (ProgressHandlerTest, fullConstructor)
 
 TEST_F (ProgressHandlerTest, initialState)
 
 TEST_F (ProgressHandlerTest, interruptRequest)
 

Detailed Description

Implements class CLASS?

Homepage:\n http://www.bornagainproject.org
License:\n GNU General Public License v3 or higher (see COPYING)
Authors
Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)

Definition in file progresshandler.test.cpp.

Function Documentation

◆ TEST_F() [1/3]

TEST_F ( ProgressHandlerTest  ,
fullConstructor   
)

Definition at line 33 of file progresshandler.test.cpp.

34 {
35  size_t max_ticks = 1000;
36  int progress{0};
37  auto on_progress_change = [&progress](int value) {
38  progress = value;
39  return false;
40  };
41 
42  ProgressHandler handler(on_progress_change, max_ticks);
43 
44  handler.setCompletedTicks(100);
45  EXPECT_FALSE(handler.has_interrupt_request());
46  EXPECT_EQ(progress, 10);
47 
48  handler.setCompletedTicks(900);
49  EXPECT_FALSE(handler.has_interrupt_request());
50  EXPECT_EQ(progress, 100); // reports value in percents
51 }
Maintain information about progress of a computation.

References ModelView::ProgressHandler::has_interrupt_request(), and ModelView::ProgressHandler::setCompletedTicks().

Here is the call graph for this function:

◆ TEST_F() [2/3]

TEST_F ( ProgressHandlerTest  ,
initialState   
)

Definition at line 27 of file progresshandler.test.cpp.

28 {
29  ProgressHandler handler;
30  EXPECT_FALSE(handler.has_interrupt_request());
31 }

References ModelView::ProgressHandler::has_interrupt_request().

Here is the call graph for this function:

◆ TEST_F() [3/3]

TEST_F ( ProgressHandlerTest  ,
interruptRequest   
)

Definition at line 53 of file progresshandler.test.cpp.

54 {
55  size_t max_ticks = 1000;
56  int progress{0};
57  auto on_progress_change = [&progress](int value) {
58  progress = value;
59  return true;
60  };
61 
62  ProgressHandler handler(on_progress_change, max_ticks);
63 
64  handler.setCompletedTicks(1000);
65  EXPECT_TRUE(handler.has_interrupt_request());
66  EXPECT_EQ(progress, 100); // reports value in percents
67 
68  // checking reset
69  handler.reset();
70  EXPECT_FALSE(handler.has_interrupt_request());
71  handler.setCompletedTicks(100);
72  EXPECT_EQ(progress, 10); // reports value in percents
73 }

References ModelView::ProgressHandler::has_interrupt_request(), ModelView::ProgressHandler::reset(), and ModelView::ProgressHandler::setCompletedTicks().

Here is the call graph for this function: