BOOST_NOINLINE boost::stacktrace::stacktrace rec2(int i) { if (i < 5) { if (!i) return boost::stacktrace::stacktrace(); return rec2(--i); } return rec2(i - 2); }
TEST(Recording_test, data_access) { std::vector<Section> sec_list(16, Section(32768)); Channel ch(sec_list); Recording rec1(ch); int chsize = rec1[0].size(); int secsize = rec1[0][rec1[0].size()-1].size(); EXPECT_EQ( rec1[0][chsize-1][secsize-1], 0 ); EXPECT_THROW( rec1.at(1), std::out_of_range ); EXPECT_THROW( rec1[0].at(chsize), std::out_of_range ); EXPECT_THROW( rec1[0][chsize-1].at(secsize), std::out_of_range ); std::vector<Channel> ch_list(4, Channel(16, 32768)); Recording rec2(ch_list); int recsize = rec2.size(); chsize = rec2[recsize-1].size(); secsize = rec2[recsize-1][rec2[recsize-1].size()-1].size(); EXPECT_EQ( rec2[recsize-1][chsize-1][secsize-1], 0 ); EXPECT_THROW( rec2.at(recsize), std::out_of_range ); EXPECT_THROW( rec2[recsize-1].at(chsize), std::out_of_range ); EXPECT_THROW( rec2[recsize-1][chsize-1].at(secsize), std::out_of_range ); Recording rec3(4, 16, 32768); recsize = rec3.size(); chsize = rec3[recsize-1].size(); secsize = rec3[recsize-1][rec3[recsize-1].size()-1].size(); EXPECT_EQ( rec3[recsize-1][chsize-1][secsize-1], 0 ); EXPECT_THROW( rec3.at(recsize), std::out_of_range ); EXPECT_THROW( rec3[recsize-1].at(chsize), std::out_of_range ); EXPECT_THROW( rec3[recsize-1][chsize-1].at(secsize), std::out_of_range ); }
void StateMenu2::om_draw() { // draw the menu int h = gdata.settings->getScreenHeight(); int w = gdata.settings->getScreenWidth(); for (int i = 0; i < om_items.size(); ++i) { int x = w-ITEM_WIDTH; int y = h-BOTTOM_BUFFER-(om_items.size()-i)*ITEM_SPACING; int indent = 0; if (i == om_selected){ //draw rectangle sf::RectangleShape rec(sf::Vector2f(BOX_WIDTH,ITEM_SPACING)); rec.setPosition(x-10,y+5); rec.setFillColor(sf::Color::White); gdata.window->draw(rec); if (i < om_items.size() - 2) { sf::RectangleShape rec2(sf::Vector2f(OBOX_WIDTH,ITEM_SPACING)); rec2.setPosition(x-OBOX_WIDTH - 20,y+5); rec2.setFillColor(sf::Color::White); gdata.window->draw(rec2); prev.setPosition(x-OBOX_WIDTH-20,y+5); gdata.window->draw(prev); next.setPosition(x-20-33,y+5); gdata.window->draw(next); } font.setColor(sf::Color::Black); indent = 20; } else { font.setColor(sf::Color::White); indent = 0; } font.drawString(x+indent,y,om_items.at(i)); // some hard coding here string text = ""; if (i == 0) text = o_res.at(res_index); else if (i == 1) text = fullscreen ? "fullscreen" : "windowed"; else if (i == 2) text = vsync ? "on" : "off"; else if(i == 3) text = gz::toString(fps); else if(i == 4) text = gz::toString(sfx_vol); else if(i == 5) text = gz::toString(mus_vol); font.drawString(x - 100,y,text,Align::RIGHT); } }
void rec2(int a,int b) { if (a==b) { printf("%d\n",a); return; } if (a<b) { printf("%d ",a); rec2(a+1,b); } if (b<a) { printf("%d ",a); rec2(a-1,b); } }
void rec2 (int *p, int x) { int i = 0; // the first call if (x == 0) { rec2(&i, 1); *p = i; // the second call } else { *p = 9; i = 0; } }
void rec2( const Int& k, const Int& s, const Int& x ) { if ( k >= N ) return; if ( k >= std::min(N, Int(5)) ) return; S.insert(x); for ( Int i = 0; i < N; ++ i ) { Int bi = Int(1) << i; if ( s & bi ) continue; rec2(k + 1, s | bi, x + A[i]); } }
int main () { int a = 1; rec1(0); assert(t == 5); rec2(&a, 0); printf("a = %d\n", a); assert(a == 9); a = fact(6); assert(a == 720); return 0; }
TEST_F(ShapeTest, ConstructOverLoad) { Rectangle rec; shape = &rec; ASSERT_EQ(0, shape->get_dimension1()); Rectangle rec2(10); shape = &rec2; ASSERT_EQ(10, shape->get_dimension1()); Triangle tri; shape = &tri; ASSERT_EQ(1, shape->get_dimension1()); Triangle tri2(30); shape = &tri2; ASSERT_EQ(30, shape->get_dimension1()); }
void task2() { int a,b; printf("Введите а и b\n"); scanf("%d %d",&a,&b); printf("Выполнить задание рекурсивно или нет?\n1-рекурсивно\n2-не рекурсивно\n"); int q; scanf("%d",&q); if (q==1) { rec2(a,b); return; } if (q==2) { notrec2(a,b); return; } else printf("Вы ввели что-то не то"); }
// draw background of widget window void CodeMiniMap::drawBackground(QPainter *painter, const QRectF &rect) { Q_UNUSED(rect); if (codepixmap != 0) { QPixmap pm = codepixmap->scaled(int(sceneRect().width()),int(sceneRect().height()*zoomlevel),Qt::IgnoreAspectRatio,Qt::SmoothTransformation); painter->drawPixmap(sceneRect(),pm,QRectF(pm.rect())); } // draw upper rect QPointF intrect_top = m_intrect->mapToScene(m_intrect->boundingRect().topRight()); intrect_top.setY( intrect_top.y() + 2 ); QRectF rec1(this->mapToScene(this->rect().topLeft()),intrect_top); painter->fillRect(rec1,QBrush(QColor::fromRgbF(0, 0, 0, 0.5))); // draw lower rect QPointF intrect_bottom = m_intrect->mapToScene(m_intrect->boundingRect().bottomLeft()); intrect_bottom.setY( intrect_bottom.y() - 2 ); QRectF rec2(intrect_bottom, this->mapToScene(this->rect().bottomRight())); painter->fillRect(rec2,QBrush(QColor::fromRgbF(0, 0, 0, 0.5))); }
TEST(Recording_test, constructors) { Recording rec0; EXPECT_EQ( rec0.size(), 0 ); std::vector<Section> sec_list(16, Section(32768)); Channel ch(sec_list); Recording rec1(ch); EXPECT_EQ( rec1.size(), 1 ); EXPECT_EQ( rec1[0].size(), 16 ); EXPECT_EQ( rec1[0][0].size(), 32768 ); std::vector<Channel> ch_list(4, Channel(16, 32768)); Recording rec2(ch_list); EXPECT_EQ( rec2.size(), 4 ); EXPECT_EQ( rec2[rec2.size()-1].size(), 16 ); EXPECT_EQ( rec2[rec2.size()-1][rec2[rec2.size()-1].size()-1].size(), 32768 ); Recording rec3(4, 16, 32768); EXPECT_EQ( rec3.size(), 4 ); EXPECT_EQ( rec3[rec3.size()-1].size(), 16 ); EXPECT_EQ( rec3[rec3.size()-1][rec3[rec3.size()-1].size()-1].size(), 32768 ); }
void init_set() { S.clear(); rec2(0, 0, 0); }
void zEndpointInfo::_CheckMigration(char* name) { FILE* fdOld; unsigned char inb[2]; zRecord1 recOld; fseek(_EndpointInfoFileStream, 0L, SEEK_SET); if (fread(inb, 2, 1, _EndpointInfoFileStream) < 1) { ++errors; inb[0] = 0; } if (inb[0] > 0) { return; } fclose(_EndpointInfoFileStream); _EndpointInfoFileStream = NULL; std::string fn = std::string(name) + std::string(".save"); if (rename(name, fn.c_str()) < 0) { unlink(name); _CreateEndpointInfo(name); return; } fdOld = fopen(fn.c_str(), "rb"); // reopen old format in read only mode // Get first record from old file - is the own ZID fseek(fdOld, 0L, SEEK_SET); if (fread(&recOld, sizeof(zRecord1), 1, fdOld) != 1) { fclose(fdOld); return; } if (recOld.ownZID != 1) { fclose(fdOld); return; } _EndpointInfoFileStream = fopen(name, "wb+"); if (_EndpointInfoFileStream == NULL) { return; } zRecord rec(recOld.identifier); rec.SetOwnZIDRecord(); if (fwrite(rec._GetRecordData(), rec._GetRecordLength(), 1, _EndpointInfoFileStream) < 1) ++errors; int numRead; do { numRead = fread(&recOld, sizeof(zRecord1), 1, fdOld); if (numRead == 0) { break; } if (recOld.ownZID == 1 || recOld.validRec == 0) { continue; } zRecord rec2(recOld.identifier); rec2._SetValid(); if (recOld.rs1Valid & zRecordFlags::SASVerfied) { rec2.SetSASVerified(); } rec2.SetNewRs1Value(recOld.rs2Data); rec2.SetNewRs1Value(recOld.rs1Data); if (fwrite(rec2._GetRecordData(), rec2._GetRecordLength(), 1, _EndpointInfoFileStream) < 1) ++errors; } while (numRead == 1); fflush(_EndpointInfoFileStream); }
void rec1(){ rec2(); }
void recursive_iterator_test() { { typedef std::vector<int> subcontainer; typedef std::vector<std::vector<int>> container; typedef subcontainer::iterator subiterator; typedef container::iterator iterator; container v({ {0,1,2,3}, {4,5,6,7} }); auto first = falcon::iterator::recursive_iterator(v); auto last = std::end(v[1]); { int a[] = {0,1,2,3,4,5,6,7}; CHECK_SEQUENCE2(a, first, last); } typedef decltype(first) recursive_iterator; CHECK_NOTYPENAME_TYPE( recursive_iterator, falcon::iterator::basic_recursive_iterator< falcon::parameter_pack< iterator, subiterator > > ); recursive_iterator random(true, std::begin(v[1])+2); first = falcon::iterator::recursive_iterator(v); std::advance(first, 6); CHECK(first == random); } { typedef std::pair<int*, int*> pair2; typedef int(*r2_t)[2][2]; typedef int(*r1_t)[2]; typedef std::pair<r1_t, r1_t> pair3; typedef std::pair<r2_t, r2_t> pair4; typedef std::tuple<bool, pair4, pair3, pair2> tuple; typedef falcon::iterator::basic_recursive_iterator<falcon::parameter_pack<r2_t, r1_t, int*>> recursive_iterator; int array[3][2][2] = { {{0,1},{2,3}}, {{4,5},{6,7}}, {{8,9},{10,11}} }; auto first1 = std::begin(array); auto last1 = std::end(array); auto last2 = std::end(*(last1-1)); recursive_iterator lastrec(true, std::begin(*(last2-1))); auto rec = falcon::iterator::recursive_iterator(array); CHECK_NOTYPENAME_TYPE(decltype(rec), recursive_iterator); recursive_iterator tmp = rec; (void)tmp; recursive_iterator rec2(tuple( true, pair4(first1, last1), pair3(last2-1, last2), pair2(std::begin(*(std::begin(*first1)+2))+2, nullptr) )); { int a[] = {0,1,2,3,4,5,6,7,8,9}; int n = 10; CHECK_SEQUENCE_M2(a, rec, lastrec, CHECK(!!(n--) == (rec != *(last2-1)))); } CHECK_EQUAL_VALUE(10, *rec); CHECK(rec == *(last2-1)); CHECK(rec == lastrec); CHECK(rec.valid()); CHECK_EQUAL_VALUE(11, *++rec); CHECK(rec != *(last2-1)); CHECK(rec != lastrec); CHECK(rec.valid()); ++rec; CHECK(!rec.valid()); } { typedef std::vector<int> v1_t; typedef std::vector<v1_t> v2_t; typedef std::vector<v2_t> v3_t; v3_t cont{{{7}}}; auto rec = falcon::iterator::recursive_iterator(cont); decltype(rec) last; CHECK_EQUAL_VALUE(7, *rec); CHECK(rec != last); CHECK(rec.valid()); ++rec; CHECK(rec == last); CHECK(!rec.valid()); rec + 2l; } }
int main() { int x = __VERIFIER_nondet_int(); rec2(x); }
int rec2(int j) { if(j <= 0) return 0; return rec1(rec2(j-1)) - 1; }
int rec2(int j) { if(j <= 0) return 0; return rec2(rec1(j+1)) - 1; }