Ejemplo n.º 1
0
TEST_F(ReplacementTest, ReturnsInvalidPath) {
  Replacement Replace1(Context.Sources, SourceLocation(), 0, "");
  EXPECT_TRUE(Replace1.getFilePath().empty());

  Replacement Replace2;
  EXPECT_TRUE(Replace2.getFilePath().empty());
}
Ejemplo n.º 2
0
TEST_F(ReplacementTest, CanReplaceTextAtPositionMultipleTimes) {
  FileID ID = Context.createInMemoryFile("input.cpp",
                                         "line1\nline2\nline3\nline4");
  SourceLocation Location1 = Context.getLocation(ID, 2, 3);
  Replacement Replace1(createReplacement(Location1, 12, "x\ny\n"));
  EXPECT_TRUE(Replace1.apply(Context.Rewrite));
  EXPECT_EQ("line1\nlix\ny\nne4", Context.getRewrittenText(ID));

  // Since the original source has not been modified, the (4, 4) points to the
  // 'e' in the original content.
  SourceLocation Location2 = Context.getLocation(ID, 4, 4);
  Replacement Replace2(createReplacement(Location2, 1, "f"));
  EXPECT_TRUE(Replace2.apply(Context.Rewrite));
  EXPECT_EQ("line1\nlix\ny\nnf4", Context.getRewrittenText(ID));
}
Ejemplo n.º 3
0
void ComsumeController::initGame()
{
    char message[100];
    Size winSize = Director::getInstance()->getVisibleSize();
    auto _bg2 = LayerColor::create(Color4B(0,128,128,128), winSize.width, winSize.height);
    this->addChild(_bg2);
    _doorStatus = 0;
    switch (com_attend_type) {
        case 1:
            _sprite1 = Sprite::create("sts/sentakumono.png");
            break;
        case 2:
            _sprite1 = Sprite::create("sts/jiko_jishin_himoto.png");
            break;
        case 3:
            _sprite1 = Sprite::create("sts/mizumore_toilet.png");
            break;
        case 4:
            _sprite1 = Sprite::create("sts/jiko_mizumore.png");
            break;
            
        default:
            _sprite1 = Sprite::create("sts/sentakumono.png");
            break;
    }
    _sprite1->setScale(2.0f);
    _sprite1->setPosition(Vec2(winSize.width/2, winSize.height/2));
    addChild(_sprite1);

    //Scrollview
    auto *scroll = ScrollView::create(winSize);
    // 縦方向だけにスクロール
    scroll->setDirection(ScrollView::Direction::VERTICAL);
    addChild(scroll);
    
    com_text_ext = Replace1( com_text_ext, ",", "\n" );
    if (com_text_ext.size()==0) {
        com_text_ext = "電力消費量の予測";
    }
    com_text_ext = com_text_ext + "\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + com_attend_ext;
    auto label = LabelTTF::create(com_text_ext, "Arial Rounded MT Bold", 36);
    label->setColor(Color3B::WHITE);
    
    // 文字の開始位置を画面の上に合わせる
    // 文字データは、一番左上から表示させたいので、widthは0
    // heightはコンテンツサイズから画面縦を引いた負数にする
    label->setDimensions(Size(winSize.width,0));
    label->setDimensions
    (Size(label->getContentSize().width, label->getContentSize().height));
    // 左寄せにする
    label->setHorizontalAlignment(TextHAlignment::LEFT);
    
    // スクロールされるラベルの調整
    scroll->setContainer(label);
    scroll->setContentOffset
    (Point(0, 0 - (label->getContentSize().height - winSize.height)));
    
    //update関数の呼び出しを開始
    scheduleUpdate();
    
}