Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  TestXpcom.cpp   Sprache: C

 
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#include "gtest/gtest.h"
#include "nsCOMPtr.h"
#include "nsIRunnable.h"
#include "nsIObserver.h"
#include "mozilla/Services.h"
#include "nsIObserverService.h"

extern "C" nsIObserverService* Rust_ObserveFromRust();

TEST(RustXpcom, ObserverFromRust)
{
  nsCOMPtr<nsIObserverService> rust = Rust_ObserveFromRust();
  nsCOMPtr<nsIObserverService> cpp = mozilla::services::GetObserverService();
  EXPECT_EQ(rust, cpp);
}

extern "C" void Rust_ImplementRunnableInRust(bool* aItWorked,
                                             nsIRunnable** aRunnable);

TEST(RustXpcom, ImplementRunnableInRust)
{
  bool itWorked = false;
  nsCOMPtr<nsIRunnable> runnable;
  Rust_ImplementRunnableInRust(&itWorked, getter_AddRefs(runnable));

  EXPECT_TRUE(runnable);
  EXPECT_FALSE(itWorked);
  runnable->Run();
  EXPECT_TRUE(itWorked);
}

extern "C" void Rust_GetMultipleInterfaces(nsIRunnable** aRunnable,
                                           nsIObserver** aObserver);

TEST(RustXpcom, DynamicCastVoid)
{
  nsCOMPtr<nsIRunnable> runnable;
  nsCOMPtr<nsIObserver> observer;
  Rust_GetMultipleInterfaces(getter_AddRefs(runnable),
                             getter_AddRefs(observer));

  // They should have different addresses when `static_cast` to void*
  EXPECT_NE(static_cast<void*>(runnable.get()),
            static_cast<void*>(observer.get()));

  // These should be the same object
  nsCOMPtr<nsISupports> runnableSupports = do_QueryInterface(runnable);
  nsCOMPtr<nsISupports> observerSupports = do_QueryInterface(observer);
  EXPECT_EQ(runnableSupports.get(), observerSupports.get());

#ifndef XP_WIN
  // They should have the same address when dynamic_cast to void*
  // dynamic_cast<void*> is not supported without rtti on windows.
  EXPECT_EQ(dynamic_cast<void*>(runnable.get()),
            dynamic_cast<void*>(observer.get()));

  // The nsISupports pointer from `do_QueryInterface` should match
  // `dynamic_cast<void*>`
  EXPECT_EQ(dynamic_cast<void*>(observer.get()),
            static_cast<void*>(observerSupports.get()));
#endif
}

Messung V0.5
C=93 H=99 G=95

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge